0
votes

i cant send email using the php mailer class. here is the error i am getting.

Error

Mailer Error: The following From address failed: [email protected] : Called Mail() without being connected.

here is the code i am using.

$mail = new PHPMailer();
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.live.com'; // Specify main and backup server
$mail->Port = '465';
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'sdf'; // SMTP password
$mail->SetFrom($from, $from);
$mail->AddReplyTo($from, $from);
$mail->Subject = $subject;
$mail->MsgHTML($message);
$address = $to;
$mail->AddAddress($address, $customer_name);

if (!$mail->Send())
{
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
}
else
{
    echo "Message sent!";
    exit;
}
2
please change your email password immediately.Popnoodles
It's better to change the password to mailserver. The pass is now in history of all editLuca Rainone
you changed it on live.com, not just in the question?Popnoodles

2 Answers

0
votes

I would recommend putting the whole mail process into a try / catch block to get more information about the error as a good place to start. There could be more details in the exception which could help pinpoint the problem.

try {
    $mail->SetFrom($from, $from);
    ...
    ...
    $mail->Send();
} catch ( phpmailerException $e ) {
    echo $e->errorMessage(); 
} catch ( Exception $e ) {
    echo $e->getMessage(); 
}

I found anther question that may be of some help which may be worth looking over: Having trouble with PHPMailer

Most of all, I think its important someone point out you just posted your plain text password on the internet. You may want to change it as quickly as possible everywhere it is used.

0
votes

Add

$mail->SMTPDebug = 1; 

to get more information on what went wrong.

And try

$mail = new PHPMailer; 

at the top.