Search the Community
Showing results for tags 'phpmailer mail smtp tls'.
-
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