Hot answers tagged

38 votes

How to change the default registration email ? (plugin and/or non-plugin)

For 2018 and onwards users: Since WordPress 4.9.0 there are new filters you can use for this (no need for a plugin anymore): wp_new_user_notification_email - customise email sent to User ...
  • 691
34 votes

Disable email notification after change of password

To disable user email notification, add this in a plugin or theme: add_filter( 'send_password_change_email', '__return_false' ); FYI wp_password_change_notification() controls admin email ...
  • 1,611
30 votes

Disable email notification after change of password

To disable Admin email notification when a user resets their own password, create a Plugin (or Must Use Plugin) using the following code snippet: /** * Disable Admin Notification of User Password ...
  • 1,307
26 votes
Accepted

"Reply-to Address" Email

If and when you are using wp_mail(), then you can just set Reply-To for the $headers parameter. Exemplary usage below: $to = "abc@def.gh"; $subject = "Using Reply-To with wp_mail"; $...
21 votes

How can i change email template for new user

For 2018 and onwards users: David Gard's answer still works but is old and there's a new better/cleaner way to do this (no need for a plugin anymore). Since WordPress 4.9.0 there are new filters you ...
  • 691
19 votes
Accepted

How do you access the Product Short Description in a WooCommerce email template?

I finally tried using var_dump() on $item and $_product, which are both used in the email-order-items.php template. $_product revealed a post object, which itself has a post_excerpt property, which ...
  • 611
19 votes
Accepted

Sending multipart (text/html) emails via wp_mail() will likely get your domain banned

The following version of wp_mail() is with the patch applied of @rmccue/@MattyRob in the ticket https://core.trac.wordpress.org/ticket/15448, refreshed for 4.2.2, which allows $message to be an array ...
  • 4,328
14 votes
Accepted

Do something after sending email

Using the PHPMailer class with an action callback: I did some digging into the PHPMailer class and found that it supports a custom action. Here's how the callback is activated with the doCallback() ...
  • 64.7k
13 votes

get_user_meta() doesn't include user email?

Just wanted to let you know you have get_user_meta and get_userdata. The email address can be found using the get_userdata function. For the current user this code can apply: <?php $user_id =...
13 votes
Accepted

Email user when password is reset by admin

Here's one way to add this feature using the following flowline : The admin updates the user option page: -> edit_user_profile_update or personal_options_update hooks activated -> ...
  • 64.7k
12 votes

How to disable all WordPress emails modularly and programatically?

Option 1: Remove the 'to' argument from wp_mail function in WordPress, it will keep your system running without sending any default WordPress emails. add_filter('wp_mail','disabling_emails', 10,1); ...
12 votes
Accepted

How to set up User email verification after Signup?

You can use user_register hook add_action( 'user_register', 'my_registration', 10, 2 ); function my_registration( $user_id ) { // get user data $user_info = get_userdata($user_id); // ...
  • 1,097
11 votes

Include HTML template file in wp_mail

Here is the sample code for using output buffering. You will be able to access all the variables inside the template which are defined above "include line". WordPress: Include template in the email....
10 votes

Sending multipart (text/html) emails via wp_mail() will likely get your domain banned

TLDR, the simple solution is: add_action('phpmailer_init','wp_mail_set_text_body'); function wp_mail_set_text_body($phpmailer) { if (empty($phpmailer->AltBody)) {$phpmailer->AltBody = ...
  • 4,905
10 votes
Accepted

Disable user registration password email

You can intercept this email before it is sent using the phpmailer_init hook. By default, this hook fires before any email is sent. In the function below, $phpmailer will be an instance of ...
10 votes
Accepted

Missing URL in password reset email

The problem is the < and > which surround the reset URL in wp-login.php. You can remove them using retrieve_password_message in your theme functions.php file like below: add_filter("...
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, ...
  • 4,460
9 votes

How to change the email notification recipient (user) for new comments?

There's a great article explaining how to hook into 2 filters for this at https://web.archive.org/web/20200216075253/http://www.sourcexpress.com/customize-wordpress-comment-notification-emails/ To ...
8 votes
Accepted

Wordpress sending emails continuously. How to stop it?

The problem I think the problem here is that you're generating an infinite loop, by placing wp_mail() inside the $phpmailer->action_function callback, that fires after each email. Each time you ...
  • 64.7k
8 votes

How can I modify the default reset (lost) password email text?

To answer your specific question, "How can I modify the default reset (lost) password email text," the answer would be to use the retrieve_password_message filter. And ultimately that might be a way ...
  • 4,460
7 votes

How to disable the "Your site has updated to WordPress x.y.z" admin email?

An alternative is to create a simple Must-use plugin so this doesn't depend on the theme. Create a file wp-content/mu-plugins/disable-auto-update-mail.php <?php /* Plugin Name: Disable Auto ...
  • 5,510
7 votes
Accepted

Dynamically send pdf attached to post with contact form 7

Try this instead. There was some internal restructuring in CF7 3.9. add_action('wpcf7_before_send_mail','send_pdf'); function send_pdf( $cf7 ) { $id = $cf7->id(); if ($id==741){ ...
7 votes

How can i change email template for new user

The new user notification email is created and sent by the function wp_new_user_notification(), found in wp-includes/plugable.php There is no filter hook within this funciton that will allow you to ...
  • 3,180
7 votes
Accepted

Fwd: [Website Name] Notice of Email Change

This is a feature since 4.3.0, as part of WordPress's improved security measures (check out the source on the WordPress code reference). You can disable it with the following filter: add_filter( '...
  • 35.8k
7 votes

Best way to create a user programatically

You should read the codex page re wp_create_user. You don't describe the context in which your code runs. You shouldn't need all those require_once calls. Anyhow, in this line ...
  • 4,908
7 votes
Accepted

Change Password notification text on mail

If I understand you correctly, then you only want to change the text of the mail. This you can do via the filter hook password_change_email. No need to redeclare the function, which you actually can't ...
7 votes
Accepted

How to add headers to outgoing email?

Thanks to the above, I've realized my central mistake -- I didn't quite realize that the arguments being passed in were a multi-dimensional array. For now, I've re-implemented the function thus: ...
7 votes
Accepted

Send activation email to user after signup

For activation process you can follow following steps: As you can see user_activation_key column in wp_users table. You can make use of that column for sending user activation link. While signing up ...
7 votes

Should I use wp_mail or PHP's mail?

WordPress offers its own mailing system. I suggest you use that instead of PHP's native mail. wp_mail accepts five arguments: wp_mail( $to, $subject, $message, $headers, $attachments ); So your ...
  • 14.8k
7 votes
Accepted

How do i send mail with custom Form Data using WordPress

wp_mail is the function you are looking for. You can take the posted form data ($_POST['email'], for example) and then use it to build and execute the wp_mail function. The example below was taken ...
  • 1,266

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