NYCPHP Meetup

NYPHP.org

[nycphp-talk] sending email from PHP

Eric Rank erank at isthmus.com
Thu Jun 3 15:03:02 EDT 2004


sending email from PHPHi Corey,

Sounds like an interesting problem. I've toyed with various mail sending
scripts including phpmailer (http://phpmailer.sourceforge.net) and
pear_mail_mime with pretty good luck in multiple configurations. In the
configurations I've used, the script calls out to sendmail (in my case Exim,
which is a nice drop-in alternative to sendmail) and places the mail in the
que of the mail server. The script runs as fast as it can make a request to
the mail server. That said, I think the problem is outside php. If you're
experiencing problems communicating with sendmail, you might try clearing
out the existing que first. It looks like Michael's suggestion is much more
in depth than what I'm telling you though. I bet he's right on the money.

I haven't dealt extensively with email address verification though. I've
toyed around with various ideas, but as far as I know, outside of making
requests to the MX of the domain directly, there's not an elegant way to
handle it. In doing so, you're actually writing a mail server. Quite a task.
As such, I've just had to deal with the replies to the sender's email from
the email recipient's MX telling me that the address doesn't exist, or that
the mailbox is full, or whatever.

I'd be interested in hearing other people's solutions for email
verification. It's such an important thing to do. There's gotta be an easy
way.

Good luck!

Eric


----- Original Message ----- 
From: corey szopinski
To: NYPHP Talk
Sent: Thursday, June 03, 2004 12:19 PM
Subject: [nycphp-talk] sending email from PHP


I'm trying to build a tool to send dynamic emails (think order summary) from
PHP. I'm running into very long delays waiting for sendmail to return a
result.

For example, a person submits an order, the function that handles  the
transaction does a couple of things:

1. Sends an order confirmation to the store
2. Sends an order confirmation to the customer

The whole process can take over 1 minute, which times out the browser. I've
tracked it down the delay to sendmail verifying the remote email address.
Since sendmail talks to the remote mail server in real-time, any network
lag, or DNS lag, causes the order process to hang. In my case, it does it
twice.

I've looked at Pear Mail_Queue, and that looks interesting, but a bit
overkill. I've also looked at going around the mail() function and opening
an SMTP socket directly to sendmail (same delays... in fact when I open a
session via command line, I can see the exact step in the SMTP conversion
where the lag happens)

Here's what I'd like to do (and this would be helpful for anyone sending out
a modest volume of email)...

1. send the mail to sendmail
2. sendmail puts it into a queue
3. sendmail periodically checks this queue and sends the email.

Essentially, I'd like to fork the slow lookup stuff to the background,
returning control the browser as soon as possible. This has the added
benefit of scaling to very large emails/hour since the browser never has to
wait for sendmail (or an external server) before a visitor can move on.

I'm pretty sure that this is intrinsic to the way sendmail works, but most
of the documentation talks about the queue holding mail that's not
deliverable. What I'd like to do is put to put a delay on the email before
it's processed by sendmail.

Any ideas?

-corey




DOMANI STUDIOS

Corey Szopinski
Technology Director

corey at domanistudios.com
70 Washington St. Suite 710
Brooklyn, NY 11201
718.797.4470  x116





_______________________________________________
talk mailing list
talk at lists.nyphp.org
http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list