Closed Simek11 closed 6 years ago
I'm in a similar boat for a project β mail is being sent using the wp_mail function, but MailHog isn't catching anything and there is no MailHog log.
If someone can give us direction on how to debug this, that would be rad.
I've tried:
No luck so far.
Hey folks,
I've just had a look into this and it looks like creating a mu-plugin
with this code will get it working again:
<?php
/**
* Plugin Name: Fix MailHog
* Description: Configure WordPress on Chassis to use MailHog
* Version: 0.1
*/
function mailhog_config( $phpmailer ) {
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mailserver
$phpmailer->Host = 'localhost';
// Use SMTP authentication
$phpmailer->SMTPAuth = false;
// SMTP port number. Mailhog normally runs on port 1025
$phpmailer->Port = WP_DEBUG ? '1025' : '25';
$phpmailer->From = 'wordpress@vagrant.local';
$phpmailer->FromName = 'Chassis';
}
add_action( 'phpmailer_init', 'mailhog_config' );
Ideally we don't want Chassis putting a plugin into the content directory as we try not to put anything into that as that code should be under version control and the developer should have control over what goes into it.
I had a quick look into this and change work out what's changed to make this happen. I might try digging into this more later today. My first initial thought is that PHPMailer has probably been updated in WordPress core to introduce this issue.
Thanks @BronsonQuick. This is working and will keep me going until you get time to work out what needs changing.
Had a look at the extension to see if I could have a crack at it, but just don't quite understand enough of how Puppet works...I'd likely break something :)
@mishterk Awesome. I'm glad that's enough to keep you going for now!
Haha yeah no problem. Puppet is pretty different. Thanks for having a look into it. Most appreciated!
@BronsonQuick So, the way it should work is by configuring the mail()
function in PHP to redirect mail to the MailHog sendmail
handler. This is provisioned in php.pp. I suspect we need to update this to place it in a different spot, given all the changes we've made around that.
(You shouldn't need any config on the WP side.)
@rmccue Champion! I was hoping you'd see this and have a better idea πΊπΌ! I'll have a play around with that tonight to see if I can come up with a fix.
Thanks @BronsonQuick β appreciate the quick turnaround :+1:
@mishterk No problem! I would've got to it sooner for @Simek11 but I was on leave!
@BronsonQuick Thank you. I'm glad that everything's fine now.
I've installed MailHog extension but couldn't make it work. When I open MailHog in a browser I see some errors in JavaScript console:
I've looked for a
mailhog.log
file but the/var/log/mailhog
directory doesn't exist.My environment:
What can be a reason of this problem?