NYCPHP Meetup

NYPHP.org

[nycphp-talk] sendmail and php mail

Joshua Hart hart at saturn.med.nyu.edu
Thu Jan 4 19:36:01 EST 2007


Or it is something more fundamental; PHP might not be able to forking a
process for sendmail.  I saw that on my own system (sometimes email would be
sent and sometimes not, without a whole lot of rhyme or reason). Instead
wrote a local send_mail function which uses a SMTP connection to a mail
server, and now all email goes out reliably. :)

Joshua


On 1/4/07 7:11 PM, "Rolan Yang" <rolan at omnistep.com> wrote:

>  From what I gather, your web server's sendmail is intercepting the the
> email instead of routing it to the correct mail server because it has
> the same domain name as the recipient address? You need to manually
> create a rule in the sendmail to override that so it routes all email
> addressed to "@yourdomain.com" over to the correct external mail server.
> See the sendmail section of
> http://www.mail-abuse.com/an_rteoutgoing.html for an idea. It's been a
> long time since I hacked sendmail.
> 
> ~Rolan
> 
> 
> 
> 
> Mark Armendariz wrote:
>> Happy 2007, everyone.
>> 
>> I know this isn't directly a php, issue, but I was hoping someone here
>> might have some experience with such a thing.
>> 
>> My client has their site on one server and their their email server at
>> another hosting company.  I'm trying to send mail from a php script
>> (using the mail function) on the site.
>> 
>> I know sendmail is working correctly, as I can send email to my own
>> domain as well as to any other I've tried.  This only applies to
>> sending email internally.
>> 
>> Sendmail has a recipient check.  Basically, it talks to the
>> recipient's server and checks that the user exists before trying to
>> send the message.  Unfortunately, since the hosting server has the
>> same domain name as the mail server.
>> 
>> ** Here's the php:
>> 
>> $aHeaders = array();
>> $aHeaders[] = 'From: ' . EMAIL_DONATIONS;
>> $aHeaders[] = 'X-Mailer: PHP v' . phpversion();
>> 
>> $sSubject = 'New Donation Submitted';
>> $sMessage = 'A new donation has been submitted through the site.';
>> mail(EMAIL_DONATIONS, $sSubject, $sMessage, implode("\n", $aHeaders),
>> '-v');
>> 
>> 
>> 
>> ** Here's the verbose output of sendmail (with my domain in place of
>> the client's)
>> TheRecipient at enobrev.com... Connecting to localhost.localdomain. via relay...
>> 220 ss07.shared.server-system.net <http://ss07.shared.server-system.net>
>> ESMTP Sendmail 8.12.11.20060308/8.12.11; Thu, 4 Jan 2007 11:09:10 -0800
>> 
>>>>> EHLO laco.org <http://laco.org>
>> 250-ss07.shared.server-system.net <http://250-ss07.shared.server-system.net>
>> Hello localhost.localdomain [127.0.0.1 <http://127.0.0.1>
>> ], pleased to meet you
>> 250-ENHANCEDSTATUSCODES
>> 250-PIPELINING
>> 250-8BITMIME
>> 250-SIZE 15000000
>> 250-DSN
>> 250-ETRN
>> 250-AUTH LOGIN PLAIN
>> 250-STARTTLS
>> 250-DELIVERBY
>> 250 HELP
>>>>> STARTTLS
>> 
>> 220 2.0.0 Ready to start TLS
>>>>> EHLO enobrev.com <http://enobrev.com>
>> 250-ss07.shared.server-system.net <http://250-ss07.shared.server-system.net>
>> Hello localhost.localdomain [
>> 127.0.0.1 <http://127.0.0.1>], pleased to meet you
>> 250-ENHANCEDSTATUSCODES
>> 250-PIPELINING
>> 250-8BITMIME
>> 250-SIZE 15000000
>> 250-DSN
>> 250-ETRN
>> 250-AUTH LOGIN PLAIN
>> 250-DELIVERBY
>> 250 HELP
>>>>> MAIL From:<
>> enobrev at enobrev.com <mailto:enobrev at enobrev.com>> SIZE=300
>> AUTH=enobrev at enobrev.com <mailto:enobrev at enobrev.com>
>> 250 2.1.0 <
>> enobrev at enobrev.com <mailto:enobrev at enobrev.com>>... Sender ok
>>>>> RCPT To:<TheRecipient at enobrev.com <http://enobrev.com>>
>>>>> DATA
>> 
>> 550 5.1.1 <TheRecipient at enobrev.com <http://enobrev.com>>... User unknown
>> 503 5.0.0 Need RCPT (recipient)
>>>>> RSET
>> 250 2.0.0 Reset state
>> dead.letter..
>> . Saved message in dead.letter
>> Closing connection to localhost.localdomain.
>>>>> QUIT
>> 221 2.0.0 ss07.shared.server-system.net
>> <http://ss07.shared.server-system.net> closing connection
>> 
>> 
>> Now, I know for a fact the recipient's email exists on my client's
>> mail server (which is an exchange server).  The only thing I can
>> figure is that it's checking the local host for the recipient and not
>> finding it, and hence never sending the email.
>> 
>> Anybody ever run into this before?  Is there a switch i can use with
>> php's mail function or sendmail to get around this?
>> 
>> Thanks!!
>> 
>> Mark Armendariz
>> ------------------------------------------------------------------------
>> 
>> _______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>> 
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>> 
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
> 
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php





More information about the talk mailing list