Jump to content

Mailer Error: The following From address failed: username@gmail.com : Called Mail() without being connected


shwetapandit

Recommended Posts

i am in great need to solve this.i received the error as Mailer Error: The following From address failed: shweta.pandit2013@gmail.com : Called Mail() without being connected when try to execute my mailform.php script.any help is greatly appreciated. i change the requires settings in php.ini as

SMTP = PHP_INI_ALL
smtp_port = smtp.gmail.com
sendmail_from = PHP_INI_ALL

 

the script is:

<?php
require("PHPMailer_5.2.4/class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->SMTPAuth   = true; // SMTP authentication
$mail->Host       = "smtp.gmail.com";
$mail->SMTPSecure = "tls";
$mail->Port       = 587; // SMTP Port
$mail->SMTPDebug   = 2; // 2 to enable SMTP debug information
$mail->Username   = "abc@gmail.com"; // SMTP account username
$mail->Password   = "*******";        // SMTP account password

$mail->SetFrom($email, $name); // FROM

$mail->AddAddress('xyz@gmail.com'); // recipient email

$mail->Subject    = "Website- Contact Form"; // email subject
$mail->Body       = $msg;

$mail->Send();

if($mail->IsError()) //if(!$mail->Send())
{        echo 'Message was not sent.';
        echo 'Mailer errors: ' . $mail->ErrorInfo;
}
else
{        echo "Thank you ";
}

?>


 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.