Using wp_mail() function outside of WordPress and through PHP CLI
Using wp_mail() function outside of WordPress and through PHP CLI
Using wp_mail() function outside of WordPress and through PHP CLI
Yes. You can. There is several filters what you mentioned in your question. You can do it with WP Mail SMTP plugin. This plugin have multiple settings such as: Sender Name, Sender Email. To get it to set the envelope sender as well, you have to turn on the “Return Path” option. This stuff working … Read more
This code will allow you to call a custom function when your meta key is updated. add_action(‘updated_postmeta’,’my_meta_update’, 10, 4); function my_meta_update( $meta_id, $object_id, $meta_key, $meta_value ) { if($meta_key === ‘my_meta_key’) { // trigger email(s) // wp_mail( $to, $subject, $message, $headers, $attachments ); } } Like Shaun mentioned, you should always use an external email solution … Read more
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 remove self at the end remove_action( ‘phpmailer_init’, __function__ ); } function wpse_224496_wp_mail( $mail ) { // Example: only SMTP for emails addressed to [email protected] if ( $mail[‘to’] === … Read more
I think I found the answer on another forum discussing using Contact Form7, with the same issue I was having. This is what I got from that thread and tried. It does appear to work and does appear to be only targeting email from the default ‘WordPress’ sender name/email. // Change default WP email sender … Read more
You’d write them the same way you would any other email, the knowledge you need to do this is Email header knowledge, not WP knowledge. Those are raw email headers, and aren’t a special WP format. Since each item in the array is a line in the header of the email, we need to know … Read more
Modify the line that reads $headers .= ‘Content-type: text/html; charset=UTF-8’ . “\r\n”; to $headers .= ‘Content-Type: text/html; charset=ISO-8859-1″; and then use <br /> for the line breaks.
(I know this is a late answer, so this user has probably moved on; but I’m answering this in the hopes that if a future user ends up here seeking a similar solution, that the following will help them find it.) The problem that Postman is telling you about is that the function wp_mail() has … Read more
Unfortunately this is not widely supported, not because WordPress does not support it, but because most email clients do not support it, so it cannot be relied upon. Instead, consider using a mailing list and use the mailing lists address as the reply to field
As you have probably found, for wp_mail(): A true return value does not automatically mean that the user received the email successfully. A possible workaround is to add an email address that you have access to in the recipients list, and if the one email address receives the mail you can be reasonably (although not … Read more