Home Ask Login Register

Developers Planet

Your answer is one click away!

Caspar Wylie February 2016

Why is either PHPMailer or SendMail not working?

I have a php script that uses phpmailer:

$mail = new PHPMailer();
$mail->SMTPAuth = false;
$mail->Host = "localhost";
$mail->Port = 587;

$mail->SetFrom($from, 'BuzzZap');

$mail->Subject = $subject;
$mail->AddAddress($to, $to);
if ($mail->Send()) {
    echo "Message sent!";
    return true;
} else {
    echo "Mailer Error: " . $mail->ErrorInfo;
    return false;

(Some variables are defined elsewhere, but are definitely defined) So, I have sendmail running on port 25 and 587 (says when I run netstat -tulnp) on a live server. The script does say "successfully sent" and produces no errors, warnings, etc. Mail.log shows:

 8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601: Authentication-Warning: casparwylie: www-data set sender to billing@buzzzap.com using -f
Feb  8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601: from=billing@buzzzap.com, size=2178, class=0, nrcpts=1, msgid=<5e0e6f2a4e12ddb8524541a13b2a76a1@buzzzap.com>, relay=www-data@l$
Feb  8 17:33:23 casparwylie sm-mta[2602]: u18HXNK9002602: from=<billing@buzzzap.com>, size=2393, class=0, nrcpts=1, msgid=<5e0e6f2a4e12ddb8524541a13b2a76a1@buzzzap.com>, proto=ESMTP, dae$
Feb  8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601: to="casparwylie@googlemail.com" <casparwylie@googlemail.com>, ctladdr=billing@buzzzap.com (33/33), delay=00:00:00, xdelay=00:0$
Feb  8 17:33:23 casparwylie sm-mta[2604]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Feb  8 17:33:24 casparwylie sm-mta[2604]: u18HXNK9002602: to=<casparwylie@googlemail.com>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=122393, relay=gmail-smtp-in.l.google.com. [7$
Feb  8 17:33:26 casparwylie sendmail[2606]: u18HXQoo002606: Aut        


ZeJur February 2016

While You are sending e-mails thru SMTP located at localhost You don't have to specify SMTP related settings. So try to remove these lines:

$mail->SMTPAuth = false;
$mail->Host = "localhost";
$mail->Port = 587;

Note: don't forget to check Your SPAM folder

Post Status

Asked in February 2016
Viewed 3,314 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life