tags:

views:

19

answers:

2

Using PHP, I'm attempting to route email through AuthSMTP (a hosted SMTP service). The problem is that the PEAR mail factory automatically tries to negotiation a TLS connection with the server. Rather than simply ignoring the attempt, AuthSMTP throws an error. I need a way to explicitly tell the Mailer class not to try to use TLS. Any suggestions?

    $from = "Example <[email protected]>";
    $to = $email;
    $subject = "This is an email";

    $body_text = "plain text here";
    $body_html = "<h1>HTML here!</h1>";

    $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);

    $mime = new Mail_mime('rn');
    $mime->setTXTBody($body_text);
    $mime->setHTMLBody($body_html);

    $body = $mime->get();
    $hdrs = $mime->headers($headers);

    $host = "mail.authsmtp.com";
    $port = 26;
    $username = "my_username";
    $password = "whatever_password";

    $mailer = Mail::factory('smtp',
    array ('host' => $host,
     'auth' => true,
     'port' => $port,
     'username' => $username,
     'password' => $password));

    if (PEAR::isError($res)) {
        throw new Exception($res->getMessage());
    } else {
        return true;
    } 

AuthSMTP is giving me the following error:

SMTP: Invalid response code received from server (code: 428, response: 4.0.0 Your account is using SSL - either disable it in your email client or enable it at http://control.authsmtp.com)
A: 

Switched to using PHPMailer instead and had it working in 5 minutes.

jamieb
A: 

This can't be done with a current release of the PEAR Mail package - but is a requested feature. I've uploaded a patch so that this can be done. Hopefully a new release will be distributed soon.

kguest
Cool. I appreciate the answer and responsiveness to community feedback. I'll keep an eye on an updated version for my next project.
jamieb