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
Messages:3
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  
Picture of Michael Hosford Michael Hosford - 2012-10-03 00:19:46
Hi,

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., jsmith@test.com). 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 dSendMail2.inc.php as follows:

(somewhere beyond line 2600)

case SASL_PLAIN_EXIM_DOCUMENTATION_MODE:
// $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,
Michael

  2. Re: SMTP authentication with usernames...   Reply   Report abuse  
Picture of Joshua Parker 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  
Picture of Michael Hosford 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->setFrom("mailer@mydomain.com");

$m->setMessage("<html><head><title></title></head><body>Message goes here.</body></html>");
$m->setTo("undisclosed-recipients@mydomain.com");
$m->setBcc($recipients);

// specify SMTP send
$m->sendThroughSMTP("mail.mydomain.com", 25, "mailer@mydomain.com", "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();