Jump to content

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


shwetapandit
Go to solution Solved by 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.