How to send mail using PHP as fast as possible for mobile device api?
I'm trying to implement a fast way to send mails from a php script which is a mobile API for mobile devices which access the API via GPRS, Edge or 3G.开发者_Go百科 It should be as fast as possible so that the user doesn't have to wait to long for the http response.
I figured, I implement a separate daemon which sends then the email using a separate SMTP Server. The PHP script opens a unix domain socket to that daemon and transfers the necessary info like from, to, subject and body.
What do you thing about that approach? Is there a faster way to go?
Your idea would (or something like it) would work, but it precludes the possibility of providing feedback if there's a problem sending the email. But if you're OK with that...
Writing the conversation with the SMTP server from scratch might be harder than you think (I've done it). Using existing solutions (and there are many for sending mail from PHP, including the built-in one) would probably not be that much slower. And if you're doing it in a different thread, it's not as important that it be as fast as possible. You can either queue them up and run them sequentially from one thread, or fork a new thread for each one to send.
精彩评论