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 = "mailer@example.com";
	//Password to use for SMTP authentication
	$mail->Password = "mailerpassword";
	//Set who the message is to be sent from
	$mail->setFrom('mailer@example.com', 'Mailer do not reply');
	//Set an alternative reply-to address
	//$mail->addReplyTo('replyto@example.com', 'First Last');
	//Set who the message is to be sent to
	$mail->addAddress('receive@example.com', '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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.