Fix Zend_Mail not sending on a puPHPet Vagrant box with Mailcatcher

I’ve done this a few times but always forgot and had to go into my files etc, so again I’m making a quick post to remind myself and possibly help others!

Quite simply, it’s just a matter of adding two lines to your application.ini. Use sendmail as the transport, not smtp, and change the port number to the same number set for mailcatcher in your puPHPet config.yaml (Usually 1025).

resources.mail.transport.type = sendmail
resources.mail.transport.port = 1025

Now you’ll find that the mail will send, and if you go to http://yoursitehere.dev:1080 it should be sitting in your mailcatcher inbox! Have a nice day!

Redirecting all mail from Sendmail on PHP

Making websites, eh? Trying to write something for use on your testing server without bombarding your database victims with development spam? You need.. slurp mail! (ahem)

Here’s how to write your own sendmail client that’ll redirect all emails to the address of your choice. Create /usr/sbin/slurpmail and stick this in it!

formail -R cc X-original-cc \
-R to X-original-to \
-R bcc X-original-bcc \
-f -A"To: whoeveryouare@gmail.com" \
| /usr/sbin/sendmail -t -i

Chmod it to make it -rwxr-xr-x. Then in php.ini find the sendmail path line that reads /usr/sbin/sendmail -t -i and change it to slurpmail!

Rock and/or Roll! We are now getting all the mails that would have went to god knows who! yay! Mind and restart Apache now first!