Skip to main content
Share Your Experience: Take the 2024 Developer Survey
9 votes

How to set SMTP programmatically

The other answers to this post, while providing a working solution, don't address the security issue of storing your SMTP credentials in a plugin file or functions.php. In some cases that may be OK, ...
butlerblog's user avatar
  • 4,996
5 votes
Accepted

How to use 'phpmailer_init' SMTP settings only on certain 'wp_mail' actions?

phpmailer_init will always fire for every wp_mail() call - however, you can hook/unhook it conditionally like so: function wpse_224496_phpmailer_init( $phpmailer ) { // SMTP setup // Always ...
TheDeadMedic's user avatar
  • 36.4k
4 votes

How to setup SMTP for only one specific wp_mail()

The following is a way to handle your question. It is in two parts. First, you would create your connection as constants to be used later. The best way to do this is in wp-config.php. (You ...
butlerblog's user avatar
  • 4,996
3 votes
Accepted

Using WP_Mail on MacOS 12 (Monterey - M1)

Hi I put this function on the functions.php or in a plugin and works for me everywhere, on localhost or in any server. just need to change the strings to your email smtp settings. Only with gmail I ...
tiago calado's user avatar
3 votes

Safe to store SMTP password in wp-config.php?

I am not sure where you else you would store the SMTP credentials? I am not comfortable storing those credentials in the Database because of the trouble you mentioned you could get into if they got ...
ChristopherJones's user avatar
2 votes
Accepted

Is Postfix required for WordPress contact forms in general?

You don't need Postfix if you use an SMTP plugin like, for example, WP Mail SMTP. Such kind of plugins can send email from your Google account via SMTP. I have just checked it by stopping postfix and ...
KAGG Design's user avatar
  • 1,842
2 votes
Accepted

What is the way to hook all wordpress email

Every WordPress email usually uses wp_mail(). Which is actually a wrapper of PHPMailer. Find out this wp_mail() functions documentation and source code, you'll find some hooks there which will be ...
CodeMascot's user avatar
  • 4,527
2 votes
Accepted

Send emails with wp_mail() using SMTP configured in plugin

When you're using something like Easy WP SMTP, what you're doing is configuring things so that wp_mail() sends using your validated SMTP account rather than the generic mailer on the web server. The ...
butlerblog's user avatar
  • 4,996
1 vote

Help with cPanel and sending email

Usually when I run into email sending problems, the solution is SMTP. You can set up a free account with SendGrid and install WP Mail SMTP. I believe SendGrid is a free option in that plugin as well. ...
Faye's user avatar
  • 671
1 vote

SMTP Error: Could not authenticate

our team had enabled two factor authentication for mail so for this reason i am getting error. after disabling the two factor authentication SMTP is working.
somutesting's user avatar
1 vote
Accepted

Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce

Your premise is correct - you can connect to different STMP accounts based on whatever criteria you can build into your action function. It's a little tricky with WooCommerce because it has two email ...
butlerblog's user avatar
  • 4,996
1 vote

Error when requesting password reset email - wp authentication

Your host may be blocking the email as a 'relay', since the 'from' email is not on your domain, but on gmail. You should (normally) set the 'from' to something like [email protected] , changing '...
Rick Hellewell's user avatar
1 vote
Accepted

Wordpress 'on behalf of' email

is one of the "two email settings you updated" the one at "WooCommerce > Settings > Emails > Email Sender Options"?
brothman01's user avatar
1 vote
Accepted

Hook into and send mail using WP Mail SMTP type plugin from HTML static front page?

You're making it way more complicated than in needs to be. WP Mail SMTP is a plugin that allows you to have WP's wp_mail() function send through an SMTP account instead of relying on the web server. ...
butlerblog's user avatar
  • 4,996
1 vote
Accepted

How to configure two SMTP Server for wordpress

Disclaimer: this is clumsy, someone might have a better suggestion. But here's one idea: Leave WordPress configured with your [email protected] settings. Set up Woo with the [email protected] ...
Dan Wich's user avatar
  • 251
1 vote

Safe to store SMTP password in wp-config.php?

If you want to make it a bit safer, save the password into the database. Making additional steps necessary to access the SMTP data. You should store sensitive data encrypted, of course. Besides ...
Nicolai Grossherr's user avatar
1 vote

How to set up gmail SMTP in Wordpress

Quite likely you're using the wrong encryption/port combination. You are using port 465 for tls. Port 465 should be used for SSL Port 587 should be used for TLS
butlerblog's user avatar
  • 4,996
1 vote

How can I configure an SMTP Server?

But based solely on what you posted, the problem is the following: define( 'SMTP_USER', '[email protected]' ); // The email address I use when I log in to the wp-admin page define( 'SMTP_PASS', ...
butlerblog's user avatar
  • 4,996
1 vote
Accepted

Easy WP SMTP plugin test email failed

If you want to configure Gmail account, you need to fill Encryption type: SSL Port: 465 Requires Authentication: Yes Or you can try https://wordpress.org/plugins/wp-mail-bank/. This would help you in ...
Akshat's user avatar
  • 1,197
1 vote
Accepted

Getting 400 Error: redirect_uri_mismatch when trying to grant permission to Gmail SMTP plugin

Sorted out myself: JSON file indeed was the issue I went back to Google Developer Console and choose to create Credentials again it then gave me an option of OAuth client Id and later an option to ...
Matas Vaitkevicius's user avatar
1 vote
Accepted

Email Bounce Address

That seems to be the configured SMTP server by your hosting. It might be possible to configure this if you have CPANEL included. If that's the case, take a look at this article. It explains how you ...
Hendrik Vlaanderen's user avatar
1 vote
Accepted

Different SMTP based on domain

I believe what you need is the phpmailer_init action hook. Here is an something you can do. add_action( 'phpmailer_init', 'custom_smtp_settings' ); function custom_smtp_settings( $phpmailer ) { ...
Stephen Afam-Osemene's user avatar
1 vote
Accepted

Create mail form using PHPmailer

I suggest you first of all to separate code from markup, especially dividing your executing file like the function support_form(). Next, please try to send email without form with hard coded message. ...
Paul Burilichev's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible