Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

PHPMailer Ubuntu issue

the mail() function

Moderators: macek, egami, gesf

PHPMailer Ubuntu issue

Postby totoleheros » Sat Aug 24, 2013 10:30 pm

Hello,
I have just installed PHPMailer for Ubuntu server 12.04. It was working fine on Centos and for some reason even though it is sending email on Ubuntu, I get a weird message in the page:

"SMTP -> FROM SERVER:220 mx.google.com ESMTP t6sm11884724eel.12 - gsmtp
SMTP -> FROM SERVER: 250-mx.google.com at your service, [77.81.240.168] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS
SMTP -> FROM SERVER: 250-mx.google.com at your service, [77.81.240.168] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN 250 ENHANCEDSTATUSCODES
SMTP -> FROM SERVER:250 2.1.0 OK t6sm11884724eel.12 - gsmtp
SMTP -> FROM SERVER:250 2.1.5 OK t6sm11884724eel.12 - gsmtp
SMTP -> FROM SERVER:354 Go ahead t6sm11884724eel.12 - gsmtp
SMTP -> FROM SERVER:250 2.0.0 OK 1377412748 t6sm11884724eel.12 - gsmtp "

I have installed :
a/phpmailer in usr/lib/ as well as copied the libphp-phpmailer folder under public_html,
b/Pear,
c/ added the lines: AddHandler application/x-httpd-php .html .htm on the .htaccess file
d/google smtp ports are open on my firewall

Here is the config:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require("./libphp-phpmailer/class.phpmailer.php"); // path to the PHPMailer class
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Mailer = "smtp";
$mail->SMTPDebug = 1;
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Username = "contact@XXXXX"; // SMTP username
$mail->Password = "XXXXX"; // SMTP password
$mail->From = "contact@XXXXX";
$mail->AddAddress("contact@XXXX");
$mail->Subject = $_POST["email"];
$mail->Body = $_POST["name"];
$mail->WordWrap = 50;
$name = $_POST["name"];
$mail->Name = $name;
$email = $_POST["email"];
$mail->Content = $email;
if (!preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email)) {
echo "<br><h4 align=center>Oops, the email address you entered is not valid!</h4>";
echo "<a href='javascript:history.back(1);'><h4 align=center>Back</h4></a>";
} elseif ($name == "") {
echo "<br><h4 align=center>Oops...you forgot to insert your question!</h4>";
echo "<a href='javascript:history.back(1);'><h4 align=center>Back</h4></a>";
}
elseif(!$mail->Send()) {
echo 'Invitation request was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
include 'step2.html';
}
?>

Any help would be greatly appreciated.

Regards
totoleheros
New php-forum User
New php-forum User
 
Posts: 14
Joined: Fri Mar 30, 2012 12:09 am

Re: PHPMailer Ubuntu issue

Postby johnj » Sat Aug 24, 2013 10:59 pm

It could be because you have switched on debugging using $mail->SMTPDebug = 1; Try using $mail->SMTPDebug = 0;
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: PHPMailer Ubuntu issue

Postby totoleheros » Sat Aug 24, 2013 11:04 pm

Thank you John! It worked.
totoleheros
New php-forum User
New php-forum User
 
Posts: 14
Joined: Fri Mar 30, 2012 12:09 am


Return to PHP coding => Mail

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron