2

I have this code, which I want to use to send mails to my customers, PARAMETERS CENSORED (***):

include 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->Host = "smtp.email.it";
$mail->Port = 25; // or 587 465
$mail->IsHTML(true);
$mail->SMTPSecure = 'tls';
$mail->Username = "***";
$mail->Password = "***";
$mail->SetFrom('***');
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress('***');
 if(!$mail->Send())
    {
    echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
    {
    echo "Message has been sent";
    }

It connects but gives errors:

2013-10-13 09:13:25 CLIENT -> SERVER: EHLO *SITE_CENSORED*
2013-10-13 09:13:25 SMTP ERROR: EHLO command failed: Method EHLO is not supported.
2013-10-13 09:13:25 SMTP NOTICE: EOF caught while checking if connected
SMTP connect() failed.
Mailer Error: SMTP connect() failed.
Xriuk
  • 382
  • 2
  • 7
  • 26
  • Looks like badly configures SMTP server, phpmailer should try `HELO` if `EHLO` failed, but server closes connection after unrecognized command. You can try [changing order of these commands](https://github.com/PHPMailer/PHPMailer/blob/master/class.smtp.php#L592) – dev-null-dweller Oct 13 '13 at 09:41
  • See http://stackoverflow.com/questions/2227702/php-mailer-error – Anthony Sterling Oct 13 '13 at 09:43
  • @dev-null-dweller Now it says `Method HELO is not supported`... – Xriuk Oct 13 '13 at 10:15
  • @AnthonySterling I can use it even without SSL or TLS, is there any way to do it? – Xriuk Oct 13 '13 at 11:01

1 Answers1

4

Changing your port to 587 should work:

$mail->Port = 587; // or 587 465

I tried to telnet:

telnet smtp.email.it 25 //not working

telnet smtp.email.it 465 //not working

telnet smtp.email.it 587 //works
abstr
  • 541
  • 2
  • 5
  • strange, when I typed in commands via telnet, both HELO and EHLO worked. Are you using the latest version of PHPMailer? – abstr Oct 13 '13 at 11:14