Cannot send emails with phpmailer - smtp.com

573 Views Asked by At

I cannot send emails using the smtp server we use.

EDIT: At first I was getting the error getaddrinfo failed: name or service not known, but that has been fixed. But I am still getting the errors below.

Server: send.smtp.com
Port: 25
Use encrypted protocol: No
Authentication: requires username/password 

Things I have tried:

  • verified settings with support people at smtp.com
  • Tried different ports (80, 2525)
  • Temporarily disabled my firewall on the machine running my apache server (RHEL 7)
  • Using the IP address as for the server address

When I try to send a test email I get:

SMTP -> FROM SERVER: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: EHLO not accepted from server: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: HELO not accepted from server: 
SMTP -> ERROR: AUTH not accepted from server: 

object(SMTP)#35 (7) { 
  ["SMTP_PORT"]=> int(25) 
  ["CRLF"]=> string(2) " " 
  ["do_debug"]=> bool(true) 
  ["do_verp"]=> string(2) "on" 
  ["smtp_conn":"SMTP":private]=> resource(474) of type (stream) 
  ["error":"SMTP":private]=> array(3) { 
    ["error"]=> string(29) "AUTH not accepted from server" 
    ["smtp_code"]=> bool(false) 
    ["smtp_msg"]=> bool(false) 
  } 
  ["helo_rply":"SMTP":private]=> NULL 
} 

SMTP -> NOTICE: EOF caught while checking if connected 
SMTP -> FROM SERVER: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: EHLO not accepted from server: 

SMTP -> FROM SERVER: 
SMTP -> ERROR: HELO not accepted from server: 
SMTP -> ERROR: AUTH not accepted from server: 

object(SMTP)#35 (7) { 
  ["SMTP_PORT"]=> int(25) 
  ["CRLF"]=> string(2) " " 
  ["do_debug"]=> bool(true) 
  ["do_verp"]=> string(2) "on" 
  ["smtp_conn":"SMTP":private]=> resource(476) of type (stream) 
  ["error":"SMTP":private]=> array(3) { 
    ["error"]=> string(29) "AUTH not accepted from server" 
    ["smtp_code"]=> bool(false) 
    ["smtp_msg"]=> bool(false) 
  } 
  ["helo_rply":"SMTP":private]=> NULL 
} 

SMTP -> NOTICE: EOF caught while checking if connected

I was able to telnet:

# telnet send.smtp.com 25
Trying 192.40.165.68
Connected to send.smtp.com
Escape character is '^]'

Edit: Saw this in /var/log/maillog

May 23 08:20:38 txapone sendmail[68217]: w4MHtNJF053686: to=<[email protected]>, ctladdr=<[email protected]> (48/48), delay=18:25:15, xdelay=00:00:40, mailer=relay, pri=1740402, relay=send.smtp.com [192.40.165.69], dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHvv5c053871: to=<[email protected]>, ctladdr=<[email protected]> (48/48), delay=18:22:40, xdelay=00:00:00, mailer=relay, pri=1740402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHakO3053279: to=<[email protected]>, ctladdr=<[email protected]> (48/48), delay=18:43:52, xdelay=00:00:00, mailer=relay, pri=1830402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHcf5U053351: to=<[email protected]>, ctladdr=<[email protected]> (48/48), delay=18:41:57, xdelay=00:00:00, mailer=relay, pri=1830402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHmc4h053590: to=<[email protected]>, ctladdr=<[email protected]> (48/48), delay=18:32:00, xdelay=00:00:00, mailer=relay, pri=1830402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:22:46 txapone sendmail[68288]: w4NCMkVH068288: from=apache, size=121, class=0, nrcpts=1, msgid=<[email protected]>, relay=apache@localhost
May 23 08:22:46 txapone sendmail[68289]: w4NCMk5M068289: from=<[email protected]>, size=402, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
May 23 08:22:46 txapone sendmail[68288]: w4NCMkVH068288: [email protected], ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30121, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (w4NCMk5M068289 Message accepted for delivery)
May 23 08:23:27 txapone sendmail[68291]: w4NCMk5M068289: to=<[email protected]>, ctladdr=<[email protected]> (48/48), delay=00:00:41, xdelay=00:00:41, mailer=relay, pri=120402, relay=send.smtp.com [192.40.165.68], dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com

This is the PHP script I am using:

<?php
require("src/PHPMailer.php");
require("src/SMTP.php");
require("src/Exception.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP();
$mail->Host = "send.smtp.com"; 
$mail->SMTPAuth = true; 
$mail->Username = "[email protected]"; 
$mail->Password = "pwd";
$mail->Port = "25";
$mail->From = "[email protected]"; 
$mail->FromName = "Company"; 
$mail->AddAddress("[email protected]", "Me"); 
$mail->AddReplyTo("[email protected]", "Company"); 
$mail->WordWrap = 50; 
$mail->IsHTML(false); 
$mail->Subject = "SMTP.com Test";
$mail->Body = "SMTP.com Test Message!";
$mail->Timeout = 30;
$mail->SMTPDebug = 4;
$mail->SMTPSecure = FALSE;
$mail->SMTPAutoTLS = FALSE;
if(!$mail->Send())
{
 echo "Message could not be sent. <p>";
 echo "Mailer Error: " . $mail->ErrorInfo;
 var_dump($mail);
 //exit;
}
else
{
  echo "Message has been sent";
}


echo "<hr>";

$success = mail('[email protected]', 'Test Mail function', 'Test Mail function');
if (!$success) {
  echo "mail failed";
    $errorMessage = error_get_last()['message'];
    var_dump($errorMessage);
}
var_dump($success);

Please let me know if you need additional information/tests.

1

There are 1 best solutions below

0
AllisonC On

The end result was that smtp.com was blocking our IP address.

(I had asked them about this a couple days ago and they denied that, but today they realized they were.)