Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 180605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:36:57+00:00 2026-05-11T14:36:57+00:00

Please help me I am New in PHP and since last 5 Hours i

  • 0

Please help me I am New in PHP and since last 5 Hours i am try to semd mail and now really tired. Thanks.

Here is my code. I am using Gmail account.

include('class.phpmailer.php'); //include('class.smtp.php'); // optional, gets called from within class.phpmailer.php if not already loaded  $mail             = new PHPMailer();  $body             = $mail->getFile('contents.html'); $body             = eregi_replace('[\]','',$body);  $mail->IsSMTP(); $mail->SMTPAuth   = true;                  // enable SMTP authentication $mail->SMTPSecure = 'ssl';                 // sets the prefix to the servier $mail->Host       = 'smtp.gmail.com';      // sets GMAIL as the SMTP server $mail->Port       = 465;                   // set the SMTP port for the GMAIL server  $mail->Username   = 'hussaintalha@gmail.com';  // GMAIL username $mail->Password   = 'xxxxxxxx';            // GMAIL password  $mail->AddReplyTo('hussaintalha@gmail.com','First Last');  $mail->From       = 'hussaintalha@gmail.com.com'; $mail->FromName   = 'First Last';  $mail->Subject    = 'PHPMailer Test Subject via gmail';  //$mail->Body       = 'Hi,<br>This is the HTML BODY<br>';                      //HTML Body $mail->AltBody    = 'To view the message, please use an HTML compatible email viewer!'; // optional, comment out and test $mail->WordWrap   = 50; // set word wrap  $mail->MsgHTML($body);  $mail->AddAddress('hussaintalha@gmail.com', 'John Doe');  $mail->AddAttachment('images/phpmailer.gif');             // attachment  $mail->IsHTML(true); // send as HTML  if(!$mail->Send()) {   echo 'Mailer Error: ' . $mail->ErrorInfo; } else {   echo 'Message sent!'; } ?> 

When I run my file I get This Error:

Warning: fopen(contents.html) [function.fopen]: failed to open stream: No such file or directory in D:\xampplite\htdocs\WebEng\class.phpmailer.php on line 1870

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport ‘ssl’ – did you forget to enable it when you configured PHP?) in D:\xampplite\htdocs\WebEng\class.smtp.php on line 122 Mailer Error: SMTP Error: Could not connect to SMTP host.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:36:58+00:00Added an answer on May 11, 2026 at 2:36 pm

    First of all when you get error messages then that’s great! Because in 90% of the cases you find that others have had them too and therefore you’ll find plenty of information on the internet about this error message.

    So step 1 when getting an error message you don’t know yet is always open google and copy paste it there. But, take out any paths or other things which are uniquely connected to your system.

    Then about your errors. Especially xampp light doesn’t support SSL. Maybe you try an easier sendmail example first. Like a very small one and then increase it step by step. That’s what I always do, when I don’t know why something doesn’t work. I start with one line and see what it does, then I add another and so forth.

    Let’s say you start with this and see if it works:

    <?php  include('class.phpmailer.php');  $mail             = new PHPMailer();  $mail->IsSMTP(); $mail->SMTPAuth   = true;                  // enable SMTP authentication $mail->Host       = 'smtp.gmail.com';      // sets GMAIL as the SMTP server $mail->Port       = 465;                   // set the SMTP port for the GMAIL server $mail->Username   = 'hussaintalha@gmail.com';  // GMAIL username $mail->Password   = 'xxxxxxxx';            // GMAIL password  $mail->From       = 'hussaintalha@gmail.com'; $mail->Subject    = 'PHPMailer Test Subject via gmail'; $mail->Body       = 'Hi, this is a test';            $mail->AddAddress('hussaintalha@gmail.com', 'Hussain');  $mail->send(); ?> 

    oh, and btw. your mail from has a .com too many!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to PHP, please help me with the stuff. Below is the
Can any one please help me? I am new to php, currently I am
Please help me to write a trigger that adds new rows to a table.
I am new in CSS so please help me in this problem. I hope
I am quite new to programming, i have a question please help me. (
Please help! I'm really at my wits' end. My program is a little personal
Please help, I am stuck here --- irb> a = line of text\n line
please help me select c.. Here's the HTML code: <div id=a> <div id=b></div> <div
Why the mail function not sending mail to me ,Could any one please help
Im new to php and javascript so please bear with me. index.php : <?php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.