Is there a SMTP mail transfer library in PHP

2019-02-20 19:59发布

问题:

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.

回答1:

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.



回答2:

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



回答3:

SwiftMailer is the only library you'll need.



回答4:

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



回答5:

Here is something I wrote. It's quite minimal and I don't know how well it performs, but I wrote it with the intention of replacing sendmail, meaning that it will take a message, lookup all the MX records for the recipient domains, contact those mail servers and deliver a message for the corresponding recipients. It worked well enough for me at the time.

https://github.com/denvertimothy/ThriveSMTP

It's been a long time since I've used it, but I threw it up on Github just now.



回答6:

I used http://www.mailerq.com/ which works cool. Its a queue based mail transfer agent. It requires rabbitmq. It provides multiple worker as well.easy to store in database. It provided management console as well. worth to check it



标签: php smtp