Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

MailHog doesn't catch emails sent by PHP #2041

Closed
MblKiTA opened this issue Dec 9, 2015 · 3 comments
Closed

MailHog doesn't catch emails sent by PHP #2041

MblKiTA opened this issue Dec 9, 2015 · 3 comments

Comments

@MblKiTA
Copy link

MblKiTA commented Dec 9, 2015

$ php -r "mail('test@test.com', 'test', 'test');"
2015/12/09 16:44:17 Using in-memory storage
2015/12/09 16:44:17 [SMTP] Binding to address: 0.0.0.0:1025
2015/12/09 16:44:17 [SMTP] Error listening on socket: listen tcp 0.0.0.0:1025: bind: address already in use

Fixed this by installing ssmtp and updating /etc/php5/cli/conf.d/zzzz_custom.ini to:
;sendmail_path='/usr/local/bin/mailhog'
sendmail_path='/usr/sbin/ssmtp -t'

/etc/ssmtp/ssmtp.conf:
...
mailhub=localhost:1025
...

Possibly there are better ways but this one worked for me.

My config.yml:
http://pastebin.com/jGqghAqF

@jtreminio
Copy link
Member

;sendmail_path='/usr/local/bin/mailhog'

You actually want this to be

sendmail_path='/usr/local/bin/mailhog sendmail foo@example.com'

See: https://github.com/puphpet/puphpet/blob/master/archive/puphpet/puppet/manifests/Php.pp#L204

@Artistan
Copy link

Artistan commented Jan 3, 2017

FYI for others looking for why MailHog may not be catching Php SMTP emails.

check your ports! if you are using a Mail::factory or other class for SMTP emails, then it may default to port 25. MailHog configuration defaults to port 1025.

@inoas
Copy link

inoas commented Apr 24, 2017

@Artistan thanks.

basically:

  1. standard puphpet setup (mid 2017)
  2. vagrant ssh; sudo apt-get install postfix; confirm all defaults (use tab/arrows, enter to navigate)
  3. set your app's smtp port to 1025 for local testing
  4. send a mail via some form or other means that will go via smtp/sendmail 1025
  5. yourlocaldomain.dev:1025

I am used to CakePHP3 (where things are a bit easier to decipher) and this way I could test Zend Framework sendmail contact forms.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants