PHP Classes

direct_delivery howto

Recommend this page to a friend!

      SMTP E-mail sending class  >  All threads  >  direct_delivery howto  >  (Un) Subscribe thread alerts  
Subject:direct_delivery howto
Summary:direct_delivery fails always except when sending to @yahoo.com
Messages:3
Author:Karim Metwalli
Date:2009-02-20 22:42:26
Update:2009-02-21 01:50:40
 

  1. direct_delivery howto   Reply   Report abuse  
Picture of Karim Metwalli Karim Metwalli - 2009-02-20 22:42:26
I need to send email in direct_delivery but I'm not finding much help about this in the other threads. Please note that everything I'm saying below is only about direct delivery.

I set direct_delivery=1. I tested sending emails to 4 test accounts: 1 at yahoo, 2 at gmail, 3 at hotmail (live.com) and 4 on a domain that I own hosted at bluehost. None of them worked. Is this expected? Has anyone seen this work? Seemed odd to me that all 4 are failing...

The first thing I did was I took a look at smtp.php and changed line 514: changed $success=0; to $success=1; Then, I got a step further: it delivered to my @yahoo.com @gmail emails. I don't understand why the code sets $success=0; when the server doesn't require authentication since that means that, at line 839, we just close and leave! Did I miss something? How could this have worked? Should I reverse my change and do something else?

Now, my 2 other test cases require some form of authentication, but I don't know what to do to make it work. I will provide below how I initialize the smtp object, an example of the conversation with the @live.com server and an example of the conversation with one of my hosts (bluehosh, which is incidentally NOT where the code in question is running).

Any help is appreciated,
Karim.

Here is how I instantiate and initialize the class:
$smtp=new smtp_class;
$smtp->localhost="localhost";
$smtp->direct_delivery=1;
$smtp->timeout=10;
$smtp->data_timeout=0;
$smtp->user="boomguestapp";
$smtp->debug=1;
$smtp->html_debug=1;
$smtp->pop3_auth_host="";
$smtp->host_name="";
$smtp->ssl=0;
$smtp->realm="";
$smtp->password="";
$smtp->authentication_mechanism="";

Here is a conversation with the @live server:

Resolving SMTP server domain "mx3.hotmail.com"...
Connecting to host address "65.55.37.120" port 25...
Connected to SMTP server "mx3.hotmail.com".
S 220 col0-mc4-f24.Col0.hotmail.com Sending unsolicited commercial or bulk e-mail to Microsoft's computer network is prohibited. Other restrictions are found at http://privacy.msn.com/Anti-spam/. Violations will result in use of equipment located in California and other states. Fri, 20 Feb 2009 14:33:19 -0800
C EHLO localhost
S 250-col0-mc4-f24.Col0.hotmail.com (3.8.0.31) Hello [64.79.209.136]
S 250-SIZE 29696000
S 250-PIPELINING
S 250-8bitmime
S 250-BINARYMIME
S 250-CHUNKING
S 250-AUTH LOGIN
S 250-AUTH=LOGIN
S 250 OK
C AUTH LOGIN
S 334 VXNlcm5hbWU6
C Ym9vbWd1ZXN0YXBw
S 334 UGFzc3dvcmQ6
C
S 535 Authentication unsuccessful

Here is a conversation with my host's server (bluehost) but which is not where I'm running smtp.php (hosting that on an other server):

Resolving SMTP server domain "metwalli.com"...
Connecting to host address "69.89.27.228" port 25...
Connected to SMTP server "metwalli.com".
S 220-box228.bluehost.com ESMTP Exim 4.69 #1 Fri, 20 Feb 2009 15:37:38 -0700
S 220-We do not authorize the use of this system to transport unsolicited,
S 220 and/or bulk e-mail.
C EHLO localhost
S 250-box228.bluehost.com Hello localhost [64.79.209.136]
S 250-SIZE 52428800
S 250-PIPELINING
S 250-AUTH PLAIN LOGIN
S 250-STARTTLS
S 250 HELP
C AUTH PLAIN Ym9vbWd1ZXN0YXBwAGJvb21ndWVzdGFwcAA=
S 535 Incorrect authentication data
C AUTH PLAIN AGJvb21ndWVzdGFwcAA=
S 435 Unable to authenticate at present
C AUTH PLAIN Ym9vbWd1ZXN0YXBwAAA=
S 435 Unable to authenticate at present

  2. Re: direct_delivery howto   Reply   Report abuse  
Picture of Karim Metwalli Karim Metwalli - 2009-02-20 23:00:09 - In reply to message 1 from Karim Metwalli
Erratum: In my previous post, I wrote "line 839", but what I meant was "line 590". Sorry about that.

  3. Re: direct_delivery howto   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2009-02-21 01:50:40 - In reply to message 1 from Karim Metwalli
Direct delivery may fail sometimes because the destination server may not be ready to accept messages right away. That is particularly true with Yahoo that implements grey listing aggressively.

Therefore you need to be ready to fallback to a regular delivery method when direct delivery fails.

I suggest that you use the test_urgent_mail.php script that comes with the MIME message. It falls back to regular delivery when direct delivery fails.

phpclasses.org/mimemessage

Also it does not make sense to use authentication with direct delivery, as authentication is only for using a local mail server to relay messages.