Quick Test Sending Mail in PHP

This is how I test my php code sending mail (with mail() function) using

Install MailCatcher

sudo apt-get install ruby ruby-dev

sudo gem install mailcatcher

Start PHP server

php -d sendmail_path="env /usr/local/bin/catchmail -f noreply@domain.com" -S 0.0.0.0:8080

Start MailCatcher

mailcatcher

Run and check

  • Run the script by visiting the page (that sends mail)
  • Check the mail at

Related tasks

  • check which php.ini is in effect by running php --ini
  • check sendmail_path has been set correctly or not by using echo phpinof() in a page
  • check the path of catchmail by running which catchmail
  • close the mailcatcher server from web interface
  • read mailcatcher help by running mailcatcher --help
  • read php help php --help
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s