wp_mail ignores the name in From field

Is there an actual [email protected] email address? And (more importantly) is the brazilbr.com the domain name of your site? If not, then your hosting place will ignore the ‘from’ email when it processes the wp_mail() command. You need to make sure that the ‘from’ email address you use in wp_mail() is an email address on … Read more

Error using wp_mail inside custom function

That’s because you have put function tps_set_html_email_content_type inside the tps_send_email, and each time you call it, it will declare the tps_set_html_email_content_type function again. Just move it out: function tps_set_html_email_content_type() { return ‘text/html’; } function tps_send_email($emailTo, $subject, $content) { add_filter( ‘wp_mail_content_type’, ‘tps_set_html_email_content_type’ ); //Send the email $mailSent = wp_mail($emailTo, $subject, $content); //Reset HTML content type back … Read more

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 ) { $phpmailer->isSMTP(); switch ($_SERVER[‘HTTP_HOST’]) { case ‘example1.com’: //name only, no http $phpmailer->Host=”smtp.example1.com”; $phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate $phpmailer->Port = 25; $phpmailer->Username=”example1″; $phpmailer->Password … Read more

Send notification email to admin for every new post published

You can use the transition_post_status hook. <?php add_action( ‘transition_post_status’, ‘custom_send_admin_email’, 10, 3 ); function custom_send_admin_email( $new_status, $old_status, $post ) { if ( ‘publish’ === $new_status && ‘publish’ !== $old_status ) { // Consider sending an email here. } } Here’s a second example that also checks for a specific post type. Note that $post is … Read more

Pass return-path additional parameter in wp_mail

Yes! There’s a plugin that does this, and it’s very simple. It uses the phpmailer_init to adjust the $phpmailer object. This is the code it uses: if ( ! function_exists( ‘wp_mail_returnpath_phpmailer_init’ ) ) { function wp_mail_returnpath_phpmailer_init( $phpmailer ) { // Set the Sender (return-path) if it is not already set if ( filter_var( $params->Sender, FILTER_VALIDATE_EMAIL … Read more

Attach a external file as attachement using wp_mail

You can’t attach from a URL. So https://ucarecdn.com/8aa17c61-bd55-4311-8b45-7d9a2efde6c5/ won’t work. You need an absolute path to the file, such as /path/to/my/file.ext. But there are some other problems with your code snippet as well. You use $email_attachement (with a ..chement…) in one place, but then $email_attachment in your wp_mail() call. Also, your “attachment” isn’t a file. … Read more

Can I use shortcodes in mail body

The shortcode generation should output a string, so that should in theory be possible if you know and trust the shortcode’s output. But many shortcodes are generated with the front-end in mind and within the loop context, so the mail context might not always work though, if they depend on conditional checks like is_single(). There … Read more

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