class.phpmailer.php works on one server and not the other

We are migrating from one server to another and on our live site we have a page that calls the class.phpmailer.php and sends email just fine.

But on the new server it keeps failing.

I am pretty sure it is a server setting (maybe a port) or a configuration setting that might be causing this.

Can anyone point me in the right direction?

Thank you
Who is Participating?
Razzmataz73Connect With a Mentor Author Commented:
We figured it out.
This worked:

How do I close/rate this ticket?
I really appreciate you guys taking the time to take a look and want to make sure you get some credit.
Ray PaseurCommented:
it keeps failing
How do you know this?  Please share the symptoms in detail so we can begin to get an understanding, thanks.
Razzmataz73Author Commented:
When the form is submitted on our live server it is fine.

But on our test server it fails to send.

I just added the $mail->SMTPDebug = 1; and echo "<br>Mailer Error: " . $mail->ErrorInfo; code, and got this (the passwords are correct though):

SMTP -> ERROR: Password not accepted from server: 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 54 uo1sm27389088vec.6 - gsmtp Failed to send mail

Mailer Error: SMTP Error: Could not connect to SMTP host.
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Razzmataz73Author Commented:
I found this thread:

And followed the suggestion to comment out:
// $mail->IsSMTP();

And it worked.

Does that mean something should be tweaked on the newer server?
Or is it just one of those things and it needs to be a little different on the new server so I should just leave it commented out?
Razzmataz73Author Commented:
Never mind,
That comment out just caused it to not use gmail.

I put up a test page at:

That calls the code:
// example on using PHPMailer with GMAIL

include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded

$mail             = new PHPMailer();

$body             = "This is a Test";

$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port

$mail->Username   = "";  // GMAIL username
$mail->Password   = "badabing33";            // GMAIL password

$mail->From       = "";
$mail->FromName   = "Webmaster";
$mail->Subject    = "This is the subject";
$mail->AltBody    = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap   = 50; // set word wrap



$mail->AddAttachment("/path/to/");             // attachment
$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment

$mail->AddAddress("","First Last");

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message has been sent";

Open in new window

And gives you the error page message:
Mailer Error: The following From address failed: : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 z4sm28305882vdj.6 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 z4sm28305882vdj.6 - gsmtp

SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 z4sm28305882vdj.6 - gsmtp
Razzmataz73Author Commented:
I grabbed that (the classes and code) right from:
Dave BaldwinFixer of ProblemsCommented:
I don't think you can use '' as the from address because it's not a Gmail address.  I think you need to use ''.  I have PHPMailer_5.2.2 and I just downloaded 5.2.4 and both work on this computer.  What server is it failing on?  Apache?  IIS?
Razzmataz73Author Commented:
Found the solution online
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.