0

Here is my code:

require_once("PHPMailer/class.phpmailer.php");

$mail = new PHPMailer();

// set authentication
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Post = 587;
$mail->Username = "myemail@gmail";
$mail->Password = "myemailpassword";

// set From:
$mail->SetFrom("myemail@gmail.com", "First Last");

// set To:
$mail->AddAddress("adifferentemail@yahoo.com", "First Last");

// set Subject:
$mail->Subject = "Subject";

// set body
$mail->IsHTML(true);
$mail->Body = "<html>
    <body>
        <p>Body Text</p>
    </body>
</html>";
$mail->AltBody = "Sorry, your email client does not support HTML messages.";

// send mail
if (!$mail->Send())
    die($mail->ErrorInfo . "\n");

I've tried changing from TLS to SSL, I've tried it with and without authentication, with SMTPSend() instead of just Send(), but I always get the "The following From address failed: myemail@gmail.com : Called Mail() without being connected" error. Any ideas where this might be coming from? I'm really new at this, so it's probably something pretty obvious...

Edited by potatopie: poorly worded title

7
Contributors
8
Replies
40
Views
4 Years
Discussion Span
Last Post by Pradeep_9
0

Hi,

You will have to let us know your server environment in which this script is running. For example.. wampp, xampp, or something else..

Looking at your codes above, it is utilizing the gmail account credentials. If you are running this script in production server environment, you will have to acknoledge the gmail confirmation request by logging in to your gmail account and click on the hard to miss red box on top the page. Make sure you are confirming the IP address on your server and NOT someone-elses.

0

I have no idea what my server environment is. Sorry... I'm using the CS50 Appliance from Harvard's CS50 course, if that helps (I'm not enrolled, so don't worry about cheating or anything). I edit PHP files, and I type in http://localhost to get to my developed site. Obviously, I've got Apache, PHP, and MySQL running.

-1

Message was not sent
PHPMailer Error: The following From address failed: dipali.sakle@gmail.com : Called Mail() without being connected
please give a solution of this error

-2

i am having the same problem as dipali sakle what can be the answer to solve it.. and does the phpmailer need specil setup in php.ini and sendmail.ini...Please do reply

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.