centos - installing MailHog on Linux virtual box to capture outgoing emails -


i wanted ease development installing mailhog on centos linux development environment in virtual box. php mail() function doesn't report issues (that is, returns true) outgoing mails did not appear in mailhog. how should set correctly?

follow these steps:

  • download appropriate mailhog version https://github.com/mailhog/mailhog/releases. use mailhog_linux_amd64 in example may need different version. assume use home directory store files. in case don't this, please, make required modifications accordingly.
  • if vm uses ip filtering should allow communication through port 8025 adding line iptable config , restarting it:

    vim /etc/sysconfig/iptables -a input -m state --state new -m tcp -p tcp --dport 8025 -j accept service iptables restart 
  • launch mailhog following command:

    ./mailhog_linux_amd64 -hostname=mylocal.vbox:8025 

    where mylocal.vbox domain name how host sees vm. should see lines detailing ip addresses , ports uses.

  • download mhsendmail here: https://github.com/mailhog/mhsendmail/releases.

  • change executable (adjust path of file accordingly):

    chmod 777 /home/you/mhsendmail_linux_amd641 
  • change php.ini use mhsendmail instead of sendmail:

    vim /etc/php.ini sendmail_path = "/home/you/mhsendmail_linux_amd64" service httpd restart 
  • view mailhog web interface host computer (use host name used above): http://mylocal.vbox:8025/. webmail interface of mailhog should appear.

  • test mail sending command line of vm oneliner:

    php -r "\$from = \$to = 'your.emailaddress@gmail.com'; \$x = mail(\$to, 'subject'.time(), 'hello world', 'from: '. \$from); var_dump(\$x);" 

    it should display true , web interface of mailhog should display new email.

  • have fun, send many emails via mail() function of php want.

some more ideas:

  • if want override default ip address , port settings should use following syntax:

    ./mailhog_linux_amd64 -ui-bind-addr=192.168.56.104:8026 -api-bind-addr=192.168.56.104:8026 -hostname=mylocal.vbox:8026 -smtp-bind-addr=192.168.56.104:8025 
  • in case have escape settings in php.ini way:

    sendmail_path = "/home/you/mhsendmail_linux_amd64 --smtp-addr=""192.168.56.104:8025""" 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -