PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 31, 2022

[FIXED] How to explicitly disable TLS with PEAR Mail factory?

 August 31, 2022     pear, php, smtp     No comments   

Issue

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 <noreply@example.com>";
    $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)

Solution

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.



Answered By - kguest
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing