PHP Classes

authorized SMTP access

Recommend this page to a friend!

      Nomad MIME Mail  >  All threads  >  authorized SMTP access  >  (Un) Subscribe thread alerts  
Subject:authorized SMTP access
Summary:Unexpected SMTP answer if sending mail via authorized SMTP srvr
Messages:12
Author:Filip Nebrensky
Date:2008-01-02 16:26:20
Update:2008-01-15 22:59:13
 
  1 - 10   11 - 12  

  1. authorized SMTP access   Reply   Report abuse  
Picture of Filip Nebrensky Filip Nebrensky - 2008-01-02 16:26:26
I like your class, because it is very simple for using and 100% suits to my requests.
But I find one error - I have authorized access to SMTP server (account in MS Outlook works well). When I try to send mail using this access, I obtain error "Error: Unexpected SMTP answer: "
Your class _smtp_send() method is leaved on the row 950

Thanks for any help, yours sincerely
Filip

  2. Re: authorized SMTP access   Reply   Report abuse  
Picture of Alejandro García González Alejandro García González - 2008-01-10 05:53:41 - In reply to message 1 from Filip Nebrensky
Hi Filip:

This is a generic error, and say about one problem in the SMTP "conversation". I recomend you to check that conversation in this way:

-----------------------------------------
$mimemail->set_smtp_log(true);

if ($mimemail->send()){
echo "The MIME Mail has been sent";
}
else {
echo $mimemail->get_smtp_log();
}
-----------------------------------------

"$mimemail->get_smtp_log()" print all conversation between my class and SMTP. Look almost the end and post here, the error.

Tnx

  3. Re: authorized SMTP access   Reply   Report abuse  
Picture of Filip Nebrensky Filip Nebrensky - 2008-01-13 16:10:48 - In reply to message 2 from Alejandro García González
Hi Alejandro,

thank you for the reply. I tried switch on the conversation logging and I got the message ending with this link:
See http://pobox.com/~djb/docs/smtplf.html
It appeared after your class tried send the "." command. I hope it is useful information for you, because I am SMTP greenhorn :-)

Bye,
Filip

  4. Re: authorized SMTP access   Reply   Report abuse  
Picture of Alejandro García González Alejandro García González - 2008-01-14 08:20:26 - In reply to message 3 from Filip Nebrensky
Hi Filip:

This error sounds familiar, but i can't remember why!!!. Anyway, we try to solve changing this lines in the constructor (function nomad_mimemail()):

---------------------
if(!defined('BR')){
define('BR', (strstr(PHP_OS, 'WIN') ? "\r\n" : "\n"), TRUE);
}
---------------------

To

---------------------
if(!defined('BR')){
define('BR', "\r\n", TRUE);
}
---------------------

Or

---------------------
if(!defined('BR')){
define('BR', "\n", TRUE);
}
---------------------

Plase tell me if that solve the problem. Anyway I was still looking and proving this error.

Tnx for you support

  5. Re: authorized SMTP access   Reply   Report abuse  
Picture of Filip Nebrensky Filip Nebrensky - 2008-01-14 14:11:31 - In reply to message 4 from Alejandro García González
Hi Alejandro,

I tried both changes of BR definition, but unfortunatelly, none of them works. The error message was the same.
I even used brute force - I send the command "." as "\r\n.\r\n" (using fwrite(...) PHP function) - but error was still the same.
Thank you for your cooperation,
bye, Filip

  6. Re: authorized SMTP access   Reply   Report abuse  
Picture of Alejandro García González Alejandro García González - 2008-01-14 19:42:10 - In reply to message 5 from Filip Nebrensky
Hi Filip:

Can you paste de last 10 lines of the SMTP log please?

Regards

  7. Re: authorized SMTP access   Reply   Report abuse  
Picture of Filip Nebrensky Filip Nebrensky - 2008-01-15 00:06:56 - In reply to message 6 from Alejandro García González
Hi Alejandro,

I wrote the simple code to invoke the error (EnvironmentSmtp... strings are my tested server-access defines):

$mimemail = new nomad_mimemail();
$mimemail->set_charset("utf-8");
$mimemail->set_from("filip@skupina.hm");
$mimemail->set_to("system@imprimis.cz");
$mimemail->set_subject("authorizing test");
$mimemail->set_text("some plain text");
$mimemail->set_smtp_host(EnvironmentSmtpHost);
$mimemail->set_smtp_auth(EnvironmentSmtpUser, EnvironmentSmtpPass);
$mimemail->set_smtp_log(true);
if ( $mimemail->send() )
echo "e-mail sent OK";
else
echo $mimemail->get_smtp_log();

There is the whole log from Firefox 2.0.0.11 ("\n" characters from $smtp_msg disappeared - I don't know why):

Error: Unespected SMTP answer:
220 willie.onebit.cz ESMTP helo smtp.imprimis.eu 250 willie.onebit.cz EHLO smtp.imprimis.eu 250-willie.onebit.cz 250-AUTH=LOGIN 250-PIPELINING 250 8BITMIME AUTH LOGIN 334 VXNlcm5hbWU6 c3lzdGVtQGltcHJpbWlzLmN6 334 UGFzc3dvcmQ6 U3lzdGVtMw== 235 go ahead MAIL FROM: filip@skupina.hm 250 ok RCPT TO: system@imprimis.cz 250 ok DATA 354 go ahead From: filip@skupina.hm Reply-To: filip@skupina.hm To: system@imprimis.cz MIME-Version: 1.0 X-Mailer: Nomad MIME Mail 1.5 Content-Type: text/plain; charset="utf-8" Subject: authorizing test some plain text . 451 See http://pobox.com/~djb/docs/smtplf.html. QUIT

Thanks,
Filip

  8. Re: authorized SMTP access   Reply   Report abuse  
Picture of Alejandro García González Alejandro García González - 2008-01-15 06:04:13 - In reply to message 7 from Filip Nebrensky
Hi Filip.

The problem is fixed, please modify this lines in the constructor:

--------------------------
if(!defined('BR')){
define('BR', "\r\n", TRUE);
}
--------------------------

And that's all.

Tnx for your Help, I Fix this problem in a new versión of this class.

  9. Re: authorized SMTP access   Reply   Report abuse  
Picture of Alejandro García González Alejandro García González - 2008-01-15 06:23:13 - In reply to message 8 from Alejandro García González
New Changes to fix thread bug.

-----------------------------------
function set_text($text){
if (!empty($text)){
$this->mail_text = preg_replace("(\r\n|\r|\n)", BR, $text);
}
}
-----------------------------------

And

-----------------------------------
function set_html($html){
if (!empty($html)){
$this->mail_html = preg_replace("(\r\n|\r|\n)", BR, $html);
}
}
-----------------------------------

Ok, that's all for this moment. Tnx Filip

  10. Re: authorized SMTP access   Reply   Report abuse  
Picture of Filip Nebrensky Filip Nebrensky - 2008-01-15 07:51:22 - In reply to message 9 from Alejandro García González
Hi Alejandro,

thank you very much for your help, my code works now. But, can you explain to me how is possible that the same code (BR definition) works today and didn't work yesterday? I'm sorry, I am very inquisitive :-)

Thanks, bye,
Filip

 
  1 - 10   11 - 12