Guest User

Untitled

a guest
Jan 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [[ $EUID -ne 0 ]]; then
  4. echo "Please run as root"
  5. exit
  6. fi
  7.  
  8. MAILHOG_URL=github.com/mailhog/MailHog
  9. MHSENDMAIL_URL=github.com/mailhog/mhsendmail
  10. MAILHOG_EXECUTABLE=/usr/local/bin/mailhog
  11. MHSENDMAIL_EXECUTABLE=/usr/local/bin/mhsendmail
  12. PHPINI_PATH="$( php --ini | grep /php.ini | awk -F: '{print $2}' )"
  13.  
  14. # verify golang installation
  15. go version
  16.  
  17. # get mailhog and mailhandler installation
  18. go get $MAILHOG_URL && go get $MHSENDMAIL_URL
  19.  
  20. # setup mailhog and mailhandler tobe accessible globally
  21. cp $GOPATH/bin/MailHog $MAILHOG_EXECUTABLE && cp $GOPATH/bin/mhsendmail $MHSENDMAIL_EXECUTABLE
  22.  
  23. # set sendmail_path value on php.ini to mailhandler executable
  24. sed -i "s/;sendmail_path.*/sendmail_path = /usr/local/bin/mhsendmail /" /etc/php/7.2/cli/php.ini
  25.  
  26. # create mailhog service to invoking on system booting
  27. cat <<EOF >/etc/systemd/system/mailhog.service
  28. [Unit]
  29. Description=Mailhog service
  30.  
  31. [Service]
  32. 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
  33.  
  34. [Install]
  35. WantedBy=multi-user.target
  36. EOF
  37.  
  38. # start, enable and check mailhog status
  39. systemctl start mailhog && systemctl enable mailhog && systemctl status mailhog
  40.  
  41. # test email submission
  42. 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