As long as your phpmailer_init hook is implemented properly there is no reason why it shouldn’t work. Have you tired it? I personally have used other SMTP plugins which hook into wp_mail() without any issues.
Thanks for your answer.
This is how I implemented the hook:
function my_phpmailer_init( $PHPMailer ){
$PHPMailer->IsSMTP();
$PHPMailer->SMTPAuth = true;
$PHPMailer->SMTPSecure = 'ssl';
$PHPMailer->Host = 'smtp.gmail.com';
$PHPMailer->Port = 465;
$PHPMailer->Username = '[email protected]';
$PHPMailer->Password = 'my_gmail_password';
}
add_action( 'phpmailer_init', 'my_phpmailer_init' );
Are there any step by step guides or something to correctly implement Email Users plugin in wordpress?
I am getting this notice upon enabling wordpress DEBUG mode
Notice: Undefined variable: from_sender in C:\wamp\www\mysite\wp-content\plugins\email-users\email_users_send_test_mail.php on line 56
Undefined variable: from_sender
WordPress uses the default email address of wordpress@yourdomain if there is no From Header pass to wp_mail in the headers parameter.
I used phpmailer_init action to send emails through gmail smtp server. but it sounds like email users does not work with it.
I’m curious how you made this conclusion? The only response returned from wp_mail is true (success) or false (failed). Email Users has no way to give you feedback on the code you’ve included.
My guess is your code is working, but Google is rejecting your authentication attempt, or perhaps the path to smtp.gmail.com:465 is blocked. I suggest you use an SMTP Plugin to accomplish what you’re attempting : Postman SMTP
While I also recommend using a SMTP plugin to do what you’re doing, in theory there shouldn’t be any reason why what you’re doing wouldn’t also work.
In looking at the source code of the error you reported above, there may be a bug. Did you use the “Send Test Notification” button on the Email Users Settings page to produce the error?
I also suggest trying to use the standard “Send to User” function to send a test email.
in theory there shouldn’t be any reason why what you’re doing wouldn’t also work.
In theory, yes. But in practice, there’s a few reasons.
For example, what if Google disabled his password auth and is requiring OAuth 2.0? Then his attempt to send a password won’t work.
What if his host is blocking his access to Gmail? Then his attempt to use SMTP over port 465 won’t work.
but it sounds like email users does not work with it.
I’m only guessing, since he hasn’t said what the actual issue is, if there is one.
I did some testing with the phpmailer_init hook (which is from this article) on my own site. The code as written above works on my wite using my Google Gmail credentials with one exception.
The “Test Notification Email” feature on the plugin settings page (Dashboard > Settings > Email Users) does not work in 4.7.8 due to the error reported above. My guess is the error has been there a while as the change that introduced it was made some time ago.
The Email Users “Send to User(s)” and “Send to Group(s)” will work correctly using the phpmailer_init hook – at least it does for me. As the post above notes, the ability to use Google for SMTP can change and if you turn on two factor authentication or app specific passwords, you will likely have more work to do.
This will be true whether using the hook above or a SMTP email plugin.
In the end, this thread highlighted a bug which I have noe fixed in v4.7.9 which I pushed out this morning. Install the update the Test Notification email should work with your phpmailer_init hook code.