PHPmailer and exchange online(Office365)

Hey guys,

I'm having an issue where we've recently upgraded to exchange online(office365) and even tho I updated the PHPmailer info on my Ubuntu server, now my web server will not send email.  I've gone through and checked the necessary settings and configured it using the following Technet article.

in the webapp I'm using the following code.

$mailer = new PHPMailer();
$mailer->SMTPSecure = "tls";
$mailer->Host              = "";
$mailer->Port               = "587"; also tested with 25
$mailer->Username    = "Authenticated username";
$mailer->Password     = "password for said authen user";
$mailer->Subject = "subject";

What I'm seeing in the mail.log of my server are 2 errors.  
Valid_hostname: Invalid Character 92 (decimal): \\032
malformed domain name in resource data of MX record for \\032

Based on these messages, I'm assuming the error is due to the dash in the MX record which is a copy and paste from the Exchange online Domain records list.  I've called M$ and they've said that is the proper configuration.

So my question is, how do I get around it with my web app?  I've gone through a bunch of resources on how to configure it but I have the exact same configuration and none of the resources I've gone to mention getting the errors above.   I'm at a loss right now what my next step is.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marcus BointonCommented:
You're apparently putting in corrupt data to get those error messages, which are nothing to do with PHPMailer; ASCII character 92 is a backslash, so it looks like those `\32` sequences are at fault - validate things before you use them!

Office365 has some issues with SSL, so you may need to disable certificate checking, as described in the troubleshooting docs.

You're setting everything up for SMTP, and then calling `isSendMail()`, which makes no sense as that will make it try to send via a local mail server, bypassing SMTP altogether. Please read the docs and examples provided with PHPMailer - you've based your code on an obsolete example too, so make sure you're using the latest version (5.2.12).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
regmandyAuthor Commented:
excellent thanks.  I'm not a coder, the application analyst is the one who wrote the app and initially it was an on premise exchange server that that code worked with.  Since we switched to exchange online, it stopped working.  

I'll update PHPmailer to the latest version and go through the documentation to see if I can correct the code.   so the \ is the issue not the dash.  thanks.  I'll report back with an update once I've gone through the provided resource.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.