Jump to content

phpmailer error explanation


anatak

Recommended Posts

I am trying to use the phpmailer class to send a mail from a webform.

I will substitute my mail server name with mail.example.com

 

I am getting these errors

SERVER -> CLIENT:
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT:
SMTP ERROR: EHLO command failed:
SMTP NOTICE: EOF caught while checking if connected
SMTP connect() failed.
Mailer Error: SMTP connect() failed.

 

I am trying to connect to my server and not to localhost.

I changed the /etc/php5/apache2/php.ini on a debian system to

and

 

SMTP = mail.example.com
; http://php.net/smtp-port
smtp_port = 465

 

then restart apache with

/etc/init.d/apache2 restart

 

Here is the code

	//Create a new PHPMailer instance
	$mail = new PHPMailer();
	//Tell PHPMailer to use SMTP
	$mail->isSMTP();
	//Enable SMTP debugging
	// 0 = off (for production use)
	// 1 = client messages
	// 2 = client and server messages
	$mail->SMTPDebug = 2;
	//Ask for HTML-friendly debug output
	$mail->Debugoutput = "html";
	//Set the hostname of the mail server
	$mail->Host = "mail.example.com";
	//Set the SMTP port number - likely to be 25, 465 or 587
	$mail->Port = 465;
	//Whether to use SMTP authentication
	$mail->SMTPAuth = true;
	// Enable encryption, "ssl" also accepted
	$mail->SMTPSecure = "tls";                            
	//Username to use for SMTP authentication
	$mail->Username = "[email protected]";
	//Password to use for SMTP authentication
	$mail->Password = "mailerpassword";
	//Set who the message is to be sent from
	$mail->setFrom('[email protected]', 'Mailer do not reply');
	//Set an alternative reply-to address
	//$mail->addReplyTo('[email protected]', 'First Last');
	//Set who the message is to be sent to
	$mail->addAddress('[email protected]', 'receive');
	//Set the subject line
	$mail->Subject = 'PHPMailer SMTP test';
	$mail->Body    = 'mailer body test: ';

	//send the message, check for errors
	if (!$mail->send()) {
    	echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
    	echo "Message sent!";
    }

any help is appreciated
 

Link to comment
https://forums.phpfreaks.com/topic/288051-phpmailer-error-explanation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.