wp_mail – Remove sitename from email subject

Finally, I wrote some code and it worked very well. I hope it helps. Put this in your functions.php file //remove sitename from email subject add_filter(‘wp_mail’, ’email_subject_remove_sitename’); function email_subject_remove_sitename($email) { $blogname = wp_specialchars_decode(get_option(‘blogname’), ENT_QUOTES); $email[‘subject’] = str_replace(“[“.$blogname.”] – “, “”, $email[‘subject’]); $email[‘subject’] = str_replace(“[“.$blogname.”]”, “”, $email[‘subject’]); return $email; }

wp_mail is undefined

You may call the function too early. You have to wait until the action ‘plugins_loaded’ fires. wp_mail() is defined in wp-includes/pluggable.php. pluggable.php is loaded in wp-settings.php after the plugins are loaded but before ‘plugins_loaded’ is called. See this answer for an example.

wp_mail script with jQuery post

Basically, you can use JavaScript to post to a WordPress function, then the WordPress function can invoke wp_mail() to send the message. A great place to start would be the useful AJAX in Plugins article on the Codex. It walks you through all the steps required to add your JavaScript on the front-end, your PHP … Read more

How do I override the Message-ID header of wp_mail function?

You can filter the $phpmailer object. Something like this should do the trick (not tested): add_action( ‘phpmailer_init’, ‘wpse_52555_msg_id’ ); function wpse_52555_msg_id( &$phpmailer ) { $msg_id = get_post_meta( get_the_ID(), ‘messageID’, TRUE ); ” !== $msg_id and $phpmailer->MessageID = $msg_id . ‘@test.com’; }

Unable to prevent function using save_post firing twice

First, you can use this hook to target only one custom type: https://developer.wordpress.org/reference/hooks/save_post_post-post_type/ This hook (and save_post) is called the first time when you click on “new …” and then the hook is called with $update = FALSE. Then to send e-mail only when the object is updated, you can test $update like this: const … Read more

Multiple email recipient using wp_mail()

Yes it’s possible, $to accepts an array or comma-separated list of email addresses to send message. You can read more here, about optional headers parameter that can add from, cc, content-type, fields. If you want to send automaticaly WordPress admin notifications, you can have a look to this.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)