We struggled with this for days, no exaggeration! And I googled like crazy, but never got an answer, and only accidentally stumbled onto the solution in the end.

The problem was that when I set up my phpmailer (5.1) to send mails using my gmail account, via google smtp (smtp.google.com), the mailer program worked. But if I tried other SMTP servers, I got the following error:

Now all the other SMTP servers were working with those details in other programs such as Outlook, but when using phpmailer the error kept saying that we can’t connect with the server. So we contacted the server IT guys and asked them why the server won’t allow us to make a connection, but when they monitored the server, they found that no connection attempts were even being made… which means we were getting the wrong error from phpmailer!

So what was the solution?
In phpmailer’s setup you can set what type of emailing method you wish to use — SMTP, sendmail or mail. You can set this using the functions IsSMTP(), IsMail() and IsSendmail(). Now we used SMTP so I called IsSMTP() to set the method to SMTP but nothing worked. So I changed the public variable myself like this :

$phpmailerinstance->Mailer = "SMTP"

And all of a sudden it worked!

So what was the catch? It was the CAPITAL LETTERS ! The IsSMTP() function sets the $Mailer variable to ‘smtp’ in lowercase which created problems, but when I manually set it to ‘SMTP’ in uppercase, it worked!

Conclusion:
Some SMTP servers (like smtp.google.com) can accept SMTP requests if you set the method to ‘smtp’ in lower case, but all SMTP servers accept the request in upper case “SMTP”

I really hope this saves someone from the trouble I went through to figure it out!

Hi Chris
After reading your comment I went through the code a few times, and I believe you might be right, I can not see that the variable Mailer is ever used externally, only internally. What I forgot to mention in my post however is that I did change some of the code in the phpmailer class. I changed the switch-case code in the send function to this:

adding the SMTP in capital letters to be sure it goes through.
I also checked the system by echoing data from the SmtpSend() function to make sure that the system is indeed using SMTP and not mail() or sendmail().

So if then indeed the Mailer variable is never used other than internally than I am still left with no explanation as to why the smtp is now working, and why it was not working prior to the change. If anyone can give me more input it will really be appreciated.

I had a issue recently while working on CakePHP which had a similar solution. I was trying to send a mail via a smtp server with cake. Everything seemed to work fine with our details and with some other test details, but when I input the client’s details I got a 550 Authentication Required errors.

I input the details into Outlook and into gmail and I could send emails just fine.

Incredible i didnt believe it could work… but i have already tried everything….. so i thought why not give a try… and it worked!!! My host provider told fsockopen is blocked… but doing what u said it worked… very strange… but worked!!