Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with SMTP authentication in PHP using PHPMailer, with Pear Mail works
    primarykey
    data
    text
    <p>I´m having trouble sending a e-mail with the PHPMailer class, but it works with PEAR Mail::factory.</p> <p>I guess the problem is with the SMTP authentication, but I couldn´t find the problem.</p> <p>The code with problem is:</p> <pre><code>&lt;?php require("class.phpmailer.php"); $mail = new PHPMailer(); $mail-&gt;IsSMTP(); // set mailer to use SMTP $mail-&gt;Host = 'mail.xxx.com.br'; // my host here $mail-&gt;SMTPAuth = true; // turn on SMTP authentication $mail-&gt;Username = 'xxx@xxx.com.br'; // a valid email here $mail-&gt;Password = '***'; // the password from email $mail-&gt;From = 'from@xxx.com.br'; $mail-&gt;SMTPDebug = true; $mail-&gt;AddReplyTo('from@xxx.com.br', 'Test'); $mail-&gt;FromName = 'Test SMTP'; $mail-&gt;AddAddress('teste@xxx.com.br', 'teste@xxx.com.br'); $mail-&gt;Subject = 'Test SMTP'; $mail-&gt;IsHTML(true); $mail-&gt;Body = '&lt;b&gt;Teste&lt;/b&gt;&lt;br&gt;&lt;h1&gt;teste 2&lt;/h1&gt;'; //$mail-&gt;Send(); if(!$mail-&gt;Send()) { echo "Message could not be sent. &lt;p&gt;"; echo "Mailer Error: " . $mail-&gt;ErrorInfo; exit; } ?&gt; </code></pre> <p>The code with PEAR that works is:</p> <pre><code>&lt;?php include('Mail.php'); include('Mail/mime.php'); $text = 'Versao em texto'; $html = '&lt;html&gt;&lt;body&gt;Versao de email em &lt;b&gt;HTML&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;'; $crlf = "\n"; $hdrs = array( 'From' =&gt; 'from@xxx.com.br', 'Subject' =&gt; 'Test - mail.php' ); $mime = new Mail_mime($crlf); $mime-&gt;setTXTBody($text); $mime-&gt;setHTMLBody($html); $body = $mime-&gt;get(); $hdrs = $mime-&gt;headers($hdrs); $mail = Mail::factory('smtp', array ('host' =&gt; 'mail.xxx.com.br', 'debug'=&gt; true, 'auth' =&gt; true, 'username' =&gt; 'xxx@xxx.com.br', 'password' =&gt; '***')); $mail-&gt;send('teste@xxx.com.br', $hdrs, $body); ?&gt; </code></pre> <p>When I run the code with problem with debug activated (SMTPDebug = True) I got:</p> <pre><code>SMTP -&gt; FROM SERVER: SMTP -&gt; get_lines(): $data was "" SMTP -&gt; get_lines(): $str is "220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 " SMTP -&gt; get_lines(): $data is "220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 " SMTP -&gt; get_lines(): $data was "220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 " SMTP -&gt; get_lines(): $str is "220-We do not authorize the use of this system to transport unsolicited, " SMTP -&gt; get_lines(): $data is "220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 220-We do not authorize the use of this system to transport unsolicited, " SMTP -&gt; get_lines(): $data was "220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 220-We do not authorize the use of this system to transport unsolicited, " SMTP -&gt; get_lines(): $str is "220 and/or bulk e-mail. " SMTP -&gt; get_lines(): $data is "220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. " SMTP -&gt; FROM SERVER: 220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. SMTP -&gt; ERROR: EHLO not accepted from server: 220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Wed, 05 Aug 2009 10:00:48 -0300 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. SMTP -&gt; get_lines(): $data was "" SMTP -&gt; get_lines(): $str is "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] " SMTP -&gt; get_lines(): $data is "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] " SMTP -&gt; get_lines(): $data was "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] " SMTP -&gt; get_lines(): $str is "250-SIZE 20971520 " SMTP -&gt; get_lines(): $data is "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 " SMTP -&gt; get_lines(): $data was "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 " SMTP -&gt; get_lines(): $str is "250-PIPELINING " SMTP -&gt; get_lines(): $data is "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING " SMTP -&gt; get_lines(): $data was "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING " SMTP -&gt; get_lines(): $str is "250-AUTH PLAIN LOGIN " SMTP -&gt; get_lines(): $data is "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING 250-AUTH PLAIN LOGIN " SMTP -&gt; get_lines(): $data was "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING 250-AUTH PLAIN LOGIN " SMTP -&gt; get_lines(): $str is "250-STARTTLS " SMTP -&gt; get_lines(): $data is "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS " SMTP -&gt; get_lines(): $data was "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS " SMTP -&gt; get_lines(): $str is "250 HELP " SMTP -&gt; get_lines(): $data is "250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP " SMTP -&gt; FROM SERVER: 250-orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] 250-SIZE 20971520 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP SMTP -&gt; get_lines(): $data was "" SMTP -&gt; get_lines(): $str is "250 orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] " SMTP -&gt; get_lines(): $data is "250 orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] " SMTP -&gt; ERROR: AUTH not accepted from server: 250 orion.bommtempo.net.br Hello admin-teste.bommtempo.com.br [200.155.129.6] SMTP -&gt; get_lines(): $data was "" SMTP -&gt; get_lines(): $str is "503 AUTH command used when not advertised " SMTP -&gt; get_lines(): $data is "503 AUTH command used when not advertised " SMTP -&gt; FROM SERVER: 503 AUTH command used when not advertised SMTP -&gt; ERROR: RSET failed: 503 AUTH command used when not advertised Message could not be sent. &lt;p&gt;Mailer Error: SMTP Error: Could not connect to SMTP host. </code></pre> <hr> <p>And the debug result of the PEAR Mail code is:</p> <pre><code>DEBUG: Recv: 220-orion.bommtempo.net.br ESMTP Exim 4.69 #1 Tue, 04 Aug 2009 19:37:10 -0300 DEBUG: Recv: 220-We do not authorize the use of this system to transport unsolicited, DEBUG: Recv: 220 and/or bulk e-mail. DEBUG: Send: EHLO localhost DEBUG: Recv: 250-orion.bommtempo.net.br Hello localhost [200.155.129.6] DEBUG: Recv: 250-SIZE 20971520 DEBUG: Recv: 250-PIPELINING DEBUG: Recv: 250-AUTH PLAIN LOGIN DEBUG: Recv: 250-STARTTLS DEBUG: Recv: 250 HELP DEBUG: Send: STARTTLS DEBUG: Recv: 220 TLS go ahead DEBUG: Send: EHLO localhost DEBUG: Recv: 250-orion.bommtempo.net.br Hello localhost [200.155.129.6] DEBUG: Recv: 250-SIZE 20971520 DEBUG: Recv: 250-PIPELINING DEBUG: Recv: 250-AUTH PLAIN LOGIN DEBUG: Recv: 250 HELP DEBUG: Send: AUTH LOGIN DEBUG: Recv: 334 VXNlcm5hbWU6 DEBUG: Send: c2lzdGVtYWFkbWluQGJvbW10ZW1wby5jb20uYnI= DEBUG: Recv: 334 UGFzc3dvcmQ6 DEBUG: Send: RVkyYVM4YnpMNU5k DEBUG: Recv: 235 Authentication succeeded DEBUG: Send: MAIL FROM: DEBUG: Recv: 250 OK DEBUG: Send: RCPT TO: DEBUG: Recv: 250 Accepted DEBUG: Send: DATA DEBUG: Recv: 354 Enter message, ending with "." on a line by itself DEBUG: Send: MIME-Version: 1.0 From: sistemaadmin@bommtempo.com.br Subject: Teste de mail - mail.php Content-Type: multipart/alternative; boundary="=_b3c5407ccf494306d78fbb35800efe65" --=_b3c5407ccf494306d78fbb35800efe65 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" Versao em texto --=_b3c5407ccf494306d78fbb35800efe65 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="ISO-8859-1" Versao de email em HTML--=_b3c5407ccf494306d78fbb35800efe65-- . DEBUG: Recv: 250 OK id=1MYSd4-0005Ky-Jw DEBUG: Send: QUIT </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload