PHP Classes

SMTP authentication with usernames containing "@"

Recommend this page to a friend!

      All In One - dSendMail2  >  All threads  >  SMTP authentication with usernames...  >  (Un) Subscribe thread alerts  
Subject:SMTP authentication with usernames...
Summary:dSendMail2 issue with AUTH and username including realm
Author:Michael Hosford
Date:2012-10-03 00:19:45
Update:2013-01-14 04:54:48

  1. SMTP authentication with usernames...   Reply   Report abuse  
Michael Hosford - 2012-10-03 00:19:46

I have used dSendMail2 for almost 2 years, and have been very happy with it. I recently moved the site to a new server with more updated software (CentOS Linux rel 6.3, PHP 5.4.6, exim 4.8.0). It's a virtual hosting setup, so mail usernames often consist of the username and the domain (e.g., This wasn't a problem on my old server (which was also a virtual host), but on the new server, dSendMail2 was unable to authenticate when sending via SMTP.

I don't know what part of the new system configuration caused this to break. I discovered that the problem was that dSendMail2 was splitting the username and the domain (or "realm"), and only used the part before the "@" when trying to authenticate with AUTH PLAIN. To fix this, I changed a line in as follows:

(somewhere beyond line 2600)

// $message="\0".$this->credentials["user"]."\0".$this->credentials["password"]; // originally was this
$message="\0".$this->credentials["user"].(strlen($this->credentials["realm"]) ? "@".$this->credentials["realm"] : "")."\0".$this->credentials["password"];

Now it authenticates successfully.

Thanks again to the authors who wrote these classes and made them available to us.

Best regards,

  2. Re: SMTP authentication with usernames...   Reply   Report abuse  
Joshua Parker - 2013-01-13 14:10:51 - In reply to message 1 from Michael Hosford
@Michael, quick question for you. Are you using this class as a mass mailer to a group of recipients? If so, did you run into any issues with every recipient being able to see who the email was sent to? Thanks.

  3. Re: SMTP authentication with usernames...   Reply   Report abuse  
Michael Hosford - 2013-01-14 04:54:48 - In reply to message 2 from Joshua Parker
Hi Joshua,

Yes, I use dSendMail2 to send to a mailing list, and no, recipients cannot see the list of email addresses. The trick is to use the setBcc() method. I do something like this ($recipients is an array of email addresses):

$m = new dSendMail2;
$m->setSubject("Message from the Mailing List");

$m->setMessage("<html><head><title></title></head><body>Message goes here.</body></html>");

// specify SMTP send
$m->sendThroughSMTP("", 25, "", "password");
$m->groupAmnt = 15; // Max destinations allowed by your servers
$m->delay = 1; // Seconds to wait before continue sending
$m->logFolder = './log';

$emailsuccess = $m->send();