Making sure that emails are despatched, and are rendered exactly how I need them to have always been a venture. Sending an email is cumbersome, and requires a mail server is set up and has to really send an e-mail to a recipient. the use of MailCatcher with Hypertext Preprocessor/Laravel allows a developer to view despatched emails and verify software mail functionality whilst aside from external factors which include mail servers. This setup assumes an IP of 192.168.10.10 is used to configure mail catcher, so replace this IP with the IP to your domicile.yaml. MailCatcher’s internet website online offers full documentation.
This manner is intended for the cutting-edge Laravel domicile box and assumes your home environment is already installed with the latest PHP7 home box.
Earlier than beginning your domicile field you will need to replace the homestead config to ahead MailCatcher’s HTTP port. upload the following lines for your dwelling house.yaml report after the alternative forwarded ports, then begin/restart your dwelling house box for the update to take effect.
<pre> - send: 1080 to: 1080 </pre>
To start, you’ll need to have Ruby installed, so type the following line within a terminal to your Homestead box.
<pre> sudo apt-get install -y ruby1.9.1-dev </pre>
The following lines are necessary to a dependency issue with an underlying dependency of MailCatcher, and you’ll still get the above error, but mail catcher will run, so input into the Homestead terminal.
<pre> sudo gem install mime-types --version "< 3" sudo gem install --conservative mailcatcher </pre>
You may receive the following error, but because of the previous lines, MailCatcher will still function:
<pre> ERROR: Error installing mailcatcher: mime-types-data requires Ruby version >= 2.0" </pre>
For projects using PHP, or PHP frameworks and application platforms like Drupal, you can set PHP’s mail configuration in your php.ini (/etc/nginx) to send via MailCatcher with by inserting the following line:
(You’ll find php.ini in /etc/php7/fpm or /etc/php5/fpm if using PHP 5)
<pre> sendmail_path = /usr/bin/env catchmail -f firstname.lastname@example.org </pre>
Update Laravel project’s configuration. If your mail settings are set using .env file, the following lines will need to replace the mail lines of your config.
<pre> MAIL_DRIVER=smtp MAIL_HOST=127.0.0.1 MAIL_PORT=1025 </pre>
Start MailCatcher with the IP as defined in the Homestead config with the following line.
<pre> mailcatcher --http-ip 192.168.10.10 </pre>
The command should output a success message:
<pre> Starting MailCatcher ==> smtp://127.0.0.1:1025 ==> http://192.168.10.10:1080 </pre>
MailCatcher can now be accessed using the URL 192.168.10.10:1080 in your browser. Simply send an email using PHP’s mail function and it will be populated in MailCatcher’s UI.