I am trying to send mail in a PHP script via the PHPMailer library. The following code has successfully sent emails in the past without warnings:
function mail_attachment($filename, $path, $mailto, $subject, $message) {
include("PHPMailer_5.2.3/class.phpmailer.php");
include("PHPMailer_5.2.3/class.smtp.php");
$email_config = parse_ini_file('email.cfg');
$from = $email_config['sender'];
$alias = $email_config['alias' ];
$smtp = $email_config['host' ];
$port = $email_config['port' ];
$mail = new PHPMailer();
$mail->SMTPDebug = 2;
$mail->IsHTML(false); // send as HTML?
$mail->WordWrap = 50; // set word wrap
$mail->IsSMTP();
$mail->Host = $smtp; // set the host SMTP server
$mail->Port = $port; // set the host SMTP port
$mail->Subject = $subject;
$mail->Body = $message;
$mail->SetFrom( $from, $alias);
$mail->AddReplyTo($from, $alias);
$mail->AddAddress($mailto);
$mail->AddAttachment($path, $filename);
var_dump( $email_config );
$sent = $mail->Send();
if(!$sent)
echo "Mailer Error: " . $mail->ErrorInfo ."\n";
else
echo "Message has been sent\n";
return $sent;
}
Suddenly the automated reporting emails stopped showing up in people's inboxes and the following messages were generated:
SMTP -> FROM SERVER:220 relay-8.dlfw.twtelecom.net ESMTP Postfix
<br />SMTP -> FROM SERVER: 250-relay-8.dlfw.twtelecom.net
250-PIPELINING
250-SIZE 25600000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
<br />SMTP -> FROM SERVER:250 2.1.0 Ok
<br />SMTP -> FROM SERVER:554 5.7.1 <localhost.localdomain>: Helo command rejected: Impossible, I am localhost
<br />SMTP -> ERROR: RCPT not accepted from server: 554 5.7.1 <localhost.localdomain>: Helo command rejected: Impossible, I am localhost
<br />SMTP Error: The following recipients failed: dataintegrity@corporate-domain.com
Mailer Error: SMTP Error: The following recipients failed: dataintegrity@corporate-domain.com<p>SMTP server error: 5.7.1 <localhost.localdomain>: Helo command rejected: Impossible, I am localhost
</p>
Mail Was NOT Successfully Sent!
Do you have any ideas on why the code stopped working?
Is the problem on my end or the remote mail server?
I have the following hostname configurations:
/etc/hostname
Dev07
/etc/hosts
127.0.0.1 localhost
127.0.1.1 lamp
#Required for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts