PEAR Mail authentication failure

We are writing a PHP program that needs to email out a confirmation. In testing we discovered that many email servers (such as Comcast) will not deliver un-authenticated emails that come from a PHP program. So to get around this we installed PEAR Mail and tried to mail using SMTP user id and password provided by our staff. We are getting the error:

authentication failure [SMTP: No supported authentication methods (code: 250, response: xxx.mailserver.com Hello [192.168.41.71] SIZE 37748736 PIPELINING DSN ENHANCEDSTATUSCODES STARTTLS X-ANONYMOUSTLS AUTH NTLM X-EXPS GSSAPI NTLM 8BITMIME BINARYMIME CHUNKING XRDST)]
Sql add failed

In doing further research it sounds like IIS needs to have a connector configured to work with Pear’s smtp.

Research notes:
It's the mail server (exchange) the one that doesn't support Digest-MD5, CRAMMD5, LOGIN or PLAIN authentication options. Those are the only authentication options that PHP supports.
You don't need to change anything on PHP, because it will automatically choose one of the authentication option on that list (Digest-MD5, CRAMMD5, LOGIN or PLAIN), the first one that your mail server supports.
You have to enable at least one of those authentication mechanisms on MS Exchange to be able to send emails from PHP using that exchange server. Otherwise you'll have to use another mail server like gmail.

The email portion of our php program:

//////////////////////////////////////////////////////////////////////////////////////////////
// Send Email to User Notifying that they downloaded the Handbook - PEAR mail SMTP Authentication
//////////////////////////////////////////////////////////////////////////////////////////////

require_once  ('C:/wamp/bin/php/php5.4.16/pear/Mail.php');
  require_once ('C:/wamp/bin/php/php5.4.16/pear/Mail/mime.php');


 $from = "Sender <user@mailserver.com>";
$to = " Recipient <xxx@comcast.net>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

 $host = "xxx.mailserver.com";
$username = "user@mailserver.com"; // edited out for this  helpdesk email only
$password = "xxxxxxx"; // edited out for this helpdesk email only

 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
$smtp = Mail::factory('smtp',
   array ('host' => $host,
     'auth' => true,
     'username' => $username,
     'password' => $password));

 $mail = $smtp->send($to, $headers, $body);

 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }

//////////////////////////////////////////////////////////////////////////////////////////////
// End of PEAR mail
//////////////////////////////////////////////////////////////////////////////////////////////

Open in new window

jzainoAsked:
Who is Participating?
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.

Ray PaseurCommented:
No points for this, please, because it's not an answer -- just advice from my experience with email.  Email seems like something that should be easy, but in fact it is not.  There are no standards, every bit of an email message can be completely phony, and this lack of accountability led to the explosion of spam and viruses that has plagued us from the early part of this millennium.  Efforts to stem the troublesome tide are uneven and often come with bizarre marketing agendas (I remember a time when AOL would not deliver email that came from Verizon servers).  And here are some of the things you cannot reliably know, without considerable programming effort, outside of the email protocols.

1. was the email delivered to the server?
2. was the email delivered to the client?
3. was the email opened by a human being?
4. were the attachments stripped away?
5. was the email forwarded?
6. was the email forwarded with forged content or bogus attachments?
7. was the email deleted?
8. was the email trapped in a spam filter?

The list goes on and on.  In 2008, I stopped sending automated emails forever.  Instead I turned to ConstantContact.com, a company that made a specialty business out of just making email work.  They offer a free trial and their rates are almost embarrassingly inexpensive when compared to the hundreds of thankless, non-value-added hours that you will spend trying to get the email to go through.  You can find competitors, of course, but ConstantContact has worked very well for several years, so I recommend them without hesitation.  I'm not affiliated in any way, other than being a satisfied customer.

Best of luck with the project, ~Ray
0

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
Dave BaldwinFixer of ProblemsCommented:
You might want to take a look at PHPMailer instead of PEAR Mail.  This https://github.com/PHPMailer/PHPMailer is the current version.
0
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
PHP

From novice to tech pro — start learning today.

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.