tags:

views:

441

answers:

5

I want to write an email transfer service and need a MTU replacement of sendmail/postfix.

I'm not looking how to deliver to a transmitting SMTP server (like a postfix listing on a SMTP port). I also don't need the receiving part of the server, bounces etc. would go to a different existing postfix.

All of it in pure PHP. SMTP is a pretty easy protocol but this would require access to the MX DNS record and other lot of details that need to be taken care of.

Why do i need this? Because most shared internet providers have insane low limits for sending out emails like 500 per day. Thats almost nothing if you want to setup even the lowest traffic email list.

EDIT: Please Note: The code needs to connect to the receivers SMTP server and deliver the message with an adapted header set (removed BCC list, added Path route). If you see a SMTP class less then 5000 lines or requires you to configure a SMTP hostip and port then this is not the stuff i'm looking for.

It needs to do all the stuff sendmail is doing just as a PHP library.

A: 

Try Zend Framework component Zend_Mail (you can use the component independently of the entire framework).

Philippe
This is not an MTU implementation. It delivers the email to your SMTP server but not the receivers SMTP server.
Lothar
A: 

Try http://php.net/mail

That does not communicate vi SMTP to deliver the mail (except maybe on windows), rather, it uses the local sendmail program or equivalent. Also, it is prone to header injection attacks if you don't sanitize your data properly.A link on that page point to the PEAR package, as I have mentioned in another answer.
DGM
A: 

We use http://sourceforge.net/projects/phpmailer/ to do SMTP email from PHP

Devin Ceartas
No also just a SMTP Client but no SMTP Mail Transfer Agent.
Lothar
A: 

I use Pear's Mail class.

EDIT

After re-reading this, I see there's more to it than just a library. You are asking to send direct to the remote MX.

Why reinvent the wheel? Set up an instance of postfix on the server, which only listens to connections from the web server... and let an MTA do what it does best. Hand off the messages from php to a real mail server and move on.

In the case of ISP's that block outbound port 25 and force the use of a smarthost, this also allows you to restrict the rate of messages sent to the smarthost.

Lastly, sending straight to the end MX from your php script is a bad idea, because if you send to me, I'll never get it. I and many other sites use "greylisting" to reduce spam, which denies all initial requests with a 450 temporary error. Real MTA's will try again, but unless you implemented a delay queue and try again, your message will never go through.

DGM
No also just a SMTP Client but no SMTP Mail Transfer Agent
Lothar
A delay queue is of course on the feature list. Before i read your answer it was just for reliability and performance (multiple MX lookups). The answer of why is that many people only have a php account or they are not able to install postfix (or don't want it for the high memory footprint on a cheap VPS) like me - by the way you can't install postfix as a non root. This unix email MTU's suck so much.And a 500 emails per day on an otherwise good webspace provider is a showstopper for a mailing list. I asked why he don't want to increase the limit but he don't want.
Lothar
Well, you can still use Pear's Net_SMTP to make the connections, and probably a Pear module to look up the MX record. Then you can check the return code from the delivery attempt and cache the message yourself if you get a 4xx error.
DGM
A: 

SwiftMailer is the only library you'll need.

Alix Axel
No also just a SMTP Client but no SMTP Mail Transfer Agent
Lothar
Oh, sorry I haven't read the whole question. I don't know any MTA implementation in PHP, sorry. =\
Alix Axel
I think you are right. After 2 days of intensive searching i found only a commerical product that you can install on your site to setup a complete email service including SMTP server like php cron jobs. But the most important parts like MX record query is available in basic PHP i think it's time to write a system on my own.
Lothar