Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ $EUID -ne 0 ]]; then
- echo "Please run as root"
- exit
- fi
- MAILHOG_URL=github.com/mailhog/MailHog
- MHSENDMAIL_URL=github.com/mailhog/mhsendmail
- MAILHOG_EXECUTABLE=/usr/local/bin/mailhog
- MHSENDMAIL_EXECUTABLE=/usr/local/bin/mhsendmail
- PHPINI_PATH="$( php --ini | grep /php.ini | awk -F: '{print $2}' )"
- # verify golang installation
- go version
- # get mailhog and mailhandler installation
- go get $MAILHOG_URL && go get $MHSENDMAIL_URL
- # setup mailhog and mailhandler tobe accessible globally
- cp $GOPATH/bin/MailHog $MAILHOG_EXECUTABLE && cp $GOPATH/bin/mhsendmail $MHSENDMAIL_EXECUTABLE
- # set sendmail_path value on php.ini to mailhandler executable
- sed -i "s/;sendmail_path.*/sendmail_path = /usr/local/bin/mhsendmail /" /etc/php/7.2/cli/php.ini
- # create mailhog service to invoking on system booting
- cat <<EOF >/etc/systemd/system/mailhog.service
- [Unit]
- Description=Mailhog service
- [Service]
- ExecStart=/usr/local/bin/mailhog -api-bind-addr 0.0.0.0:8025 -ui-bind-addr 0.0.0.0:8025 -smtp-bind-addr 127.0.0.1:1025
- [Install]
- WantedBy=multi-user.target
- EOF
- # start, enable and check mailhog status
- systemctl start mailhog && systemctl enable mailhog && systemctl status mailhog
- # test email submission
- php -r "\$from = \$to = 'your.emailaddress@gmail.com'; \$x = mail(\$to, 'subject'.time(), 'Hello World', 'From: '. \$from); var_dump(\$x);"
Add Comment
Please, Sign In to add comment