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 using -f
Feb  8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601:, size=2178, class=0, nrcpts=1, msgid=<>, relay=www-data@l$
Feb  8 17:33:23 casparwylie sm-mta[2602]: u18HXNK9002602: from=<>, size=2393, class=0, nrcpts=1, msgid=<>, proto=ESMTP, dae$
Feb  8 17:33:23 casparwylie sendmail[2601]: u18HXNFd002601: to="" <>, (33/33), delay=00:00:00, xdelay=00:0$
Feb  8 17:33:23 casparwylie sm-mta[2604]: STARTTLS=client,, 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=<>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=122393, [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