Open brothman01 opened 7 years ago
Any ideas?
Hi @brothman01
Could you give a bit more info please?
What do you mean by 'does not catch any outgoing mail' - does it make a successful connection to MailHog, and then fail to deliver the message (i.e. not in UI or API), or does it fail to even connect to MailHog, or does it appear to connect to MailHog and successful delivers but MailHog doesn't show any corresponding log output etc?
The only thing I can think of is some PHP configuration missing, or some other misconfiguration, which means emails sent by phpmailer aren't going to MailHog. If the wordpress installation is correctly pointing at MailHog, I'd expect at least a single line of log output saying the connection was successful.
Or does your work laptop have anything designed to intercept/monitor network traffic which could be interfering?
I'll leave this open for now, but it sounds like a Wordpress issue not a MailHog issue, so there's probably not a lot I can really do to help.
It’s working for me… though I went about it in a slightly different way.
NOTE: I'm testing on a WordPress site served up at <blahblahdomain>.dev
and catching mail at localhost:8025
.
brew services start mailhog
.@brothman01 Is this still an issue?
yes, I stopped trying to use mailhog for a while but now I am at it again!
I used bishless's steps from above and made an MU plugin using his code but mailhog is still not catching mail that I have another WordPress plugin I wrote sending using the mail()
function. Should I be using a different PHP function or something?
Do you have the full line from your PHP code where mail is being called?
And any relevant php.ini params? It’s been a while since I used PHP but we’ll try to get you runninh
lol sry but it's a lot of php :)
anyway, the line is: mail( "someone@example.com", "My subject", $msg );
which is being called from an asynchronous request (I know this is not simplifying anything), a request that is fired from JQuery which calls the php function that contains this line.
I did not configure php.ini which may be the problem.. I just assumed that bishless's method of using a plugin would override the php.ini anyway so I configure my mail command ports with the code:
<?php
/**
* @link
* @since 1.0.0
* @package TODO
*
* @wordpress-plugin
* Plugin Name: Use MailHog
* Description: Configure WordPress on Valet to use MailHog
* Version: 1.0.0
* Tags: local, email
*/
add_action( 'phpmailer_init', 'bish_configMH', 10, 1 );
function bish_configMH( $phpmailer ) {
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mailserver
$phpmailer->Host = 'localhost';
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = false;
// SMTP port number
// Mailhog normally run on port 1025
$phpmailer->Port = WP_DEBUG ? '1025' : '25';
// Username to use for SMTP authentication
// $phpmailer->Username = 'yourusername';
// Password to use for SMTP authentication
// $phpmailer->Password = 'yourpassword';
// The encryption system to use - ssl (deprecated) or tls
// $phpmailer->SMTPSecure = 'tls';
$phpmailer->From = 'site_adm@wp.local';
$phpmailer->FromName = 'WP DEV';
}
?>
I'm having the same issue. Well, not using Valet, not on a mac, etc; but I can't seem to make Mailhog intercept my WordPress emails.
I had the same issue. For me, it was helpful to check whether the email gets send successfully from within WordPress. So I used the hook wp_mail_failed
and checked for the proper error message:
add_action( 'wp_mail_failed', function( $error ) {
die( '<pre>' . var_dump($error) );
} );
This way, I could find out that wordpress@localhost
is no valid email address as from email for wp_mail()
.
I have two valet installs that should use mailhog services:
On my personal desktop - works perfectly. Mailhog catches all outgoing mail.
On my work laptop - cannot send mail. Mailhog does not catch any outgoing mail.
The Problem: I installed mailhog yesterday with Brew on my laptop, and the mailserver is accessible when mailhog is running, but when I try to send email from the WordPress, mailhog does not catch the outgoing mail and the email does not show up anywhere.
What I have tried:
I updated brew and installed mailhog
I set mailhog to run in the terminal everytime I want to use it ($ mailhog)
I created a plugin with the following code:
I turned on WP_DEBUG on that WordPress installation
I downloaded & installed the plugin 'WP Mail SMTP' (this is what a Google Search said to do but it did not appear to do anything)
Question:
Am I missing a step? How do I make mailhog catch outgoing mail from my WordPress installation?