WordPress new user email formatting issues

I have a WordPress site where i have Issue with the email, that user receives after creating an account. Email that a user receives, looks like this: https://tinyurl.com/y45bgy5z There is no formatting, no paragraph or no line breaks etc in the email. I have tried fixing this by adding filter for wp_new_user_notification_email but it did not worked: I have tried fixing it by using following: add_filter('wp_new_user_notification_email', 'tpkcs_welcome_email', 10, 3); function tpkcs_welcome_email($wp_new_user_notification_email, $user, $blogname) { $wp_new_user_notification_email['headers'] = 'Content-Type: text/html; charset=UTF-8'; return …
Category: Web

Woocommerce HTML email option unavailable

I am attempting to create HTML emails in woocommerce. I currently only have the plain text email option available. I have added the following to functions.php on my theme: function wps_set_content_type(){ return "text/html"; } add_filter( 'wp_mail_content_type','wps_set_content_type' ); As well I have installed the following php modules php-gd, php-xml and php-xmlrpc. I have restarted apache after installation and verified that all modules are available. The odd thing is that when I check the options locally, I have the HTML option. When …
Category: Web

About Custom Email Template Design Responsive

I created a custom email function using wp_mail() function. I did everything which is required for mail template. This function is working well. But I need it to be responsive. I found that I can use only inline css in email template. This way there are few css could applied on email template. I can't use Position property of css and other so many css property doesn't work. How can I use external css so it look responsive. Please help. …
Category: Web

Woocommerce Email show HTML source code

I updated my Woocommerce to version 5.6.0 but since that update the emails send by Woocommerce (invoice/order updates etc) will be send as HTML-source code despite it has to send a designed template. I didn't change anything on code, but maybe someone has a fix for this.
Category: Web

Unable to send custom welcome email after user register

I am trying to send a custom welcome email after user register on our website. The default role set is 'subscriber'. The email should pull some user meta values and display the same in the email. I tried the following function but somehow the email does not get delivered or even if delivered, the meta values do not show up. I put the function in my child theme's functions.php file. Any help will be highly appreciated. function user_role_update_new($user_id, $role) { …
Category: Web

How to add (and change the font of) the short product description to order page and customer's new order e-mail

I'd like to add the short product description to the e-mail that is sent to the customer when a new order is confirmed. I've added the following via a code snippets plug-in: add_filter( 'woocommerce_order_item_name', 'add_single_excerpt_to_order_item', 10, 3 ); function add_single_excerpt_to_order_item( $item_name, $item, $is_visible ){ $product_id = $item->get_product_id(); // Get the product Id $excerpt = get_the_excerpt( $product_id ); // Get the short description return $item_name . '<br><p class="item-description">' . $excerpt ; '</p>'; } It is working correctly by adding the short …
Category: Web

Is there a way to send HTML formatted emails with WordPress' wp_mail() function?

Is there an action_hook or something similar that could help me achieve this? I tried adding markup in a PHP string variable and just fired off an email with the wp_mail() function like so: $email_to = '[email protected]'; $email_subject = 'Email subject'; $email_body = "<html><body><h1>Hello World!</h1></body></html>"; $send_mail = wp_mail($email_to, $email_subject, $email_body); But it showed up as plain text? Any ideas?
Category: Web

Create custom welcome email without a plugin

Is there a way to customize the email content and subject for the welcome and verification emails sent during the registration process for Wordpress? I'd like to hook or filter in without using a plugin or the "pluggable" feature. If someone could point me in the right direction, I'd be very appreciative. Thanks!
Category: Web

Insert Current URL into MailTo link in wordpress

I'm trying to figure out a simple way to "grab current URL" and use mailto link such as: <a href="mailto:email.com?subject=Booking%20Request%20%value%&body=Hello%20Daisy%2C%0A%0AI'm%20interested%20in%20booking%20%value%%20for%202%20hours%20on%20this%20date%20%5Benter%20date%5D%20and%20this%20address%20%5Benter%20address%5D.%0A%0AI%20plan%20on%20doing%20the%20following%20activity%20%5Benter%20activity%5D.%0A%0ARegards%2C%0A%0A%5Benter%20your%20name%5D">Request Booking</a> The above is the mailto link I've created. I've stumbled upon the below to grab the URL: global $wp; $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) ); My question is how do I incorporate the above URL grabbing code into usable html code? Or perhaps there is a plugin I can use that will inject the current URL …
Category: Web

How to set wp_editor to be email friendly?

I am sending emails via wp_mail() using a text/html header. So i need html formatted content. I want to use wp_editor() to edit my custom email template options. It has a Visual and Text tab for viewing. If I write html using the Text tab, then click Visual. It looks great! I can see the preview! buuuuuut sadly it also removes my html and replaces it with some other format.. I noticed there are options with wp_editor. Is there any …
Category: Web

HTML email sent with wp_mail shows plain text

I have an HTML invoice that I want to send. I use the following function to replace some things in the HTML foreach($variables as $key => $value){ $template = str_replace('{{ '.$key.' }}', $value, $template); } After that I send the mail: $to = get_option('admin_email'); $subject = "Someone reserved from ".get_bloginfo('name'); $headers = 'From: '. $email . "\r\n" . 'Reply-To: ' . $email . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html'; add_filter( 'wp_mail_content_type', 'set_html_content_type' ); function set_html_content_type() …
Category: Web

wp_mail not sending

So I have a localhost WordPress server, and the function wp_mail workd perfectly and sends. When I put the exact same file in an actual WordPress website as a theme, it only shows me a blank screen, and doesn't send anything. Code: <?php if (isset($_POST['submit'])) { $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $company = $_POST['company']; $to = "[email protected]"; function wpse27856_set_content_type(){ return "text/html"; } add_filter( 'wp_mail_content_type','wpse27856_set_content_type' ); $msg = '<html><body><h1>Contact Service</h1><table rules="all" …
Category: Web

Using WordPress templating for HTML emails

I am working on a plugin that needs to send out an email after a form submission. I am using wp_mail() for this and it works fine. My problem is that in my code the HTML is generated by a bunch of PHP strings being added to a variable like so: $content = $html_headers; $content .= '<h1>' . the_title($post_id) . '</h1>'; $content .= '<p>' . $post_body . '</p>; ..etc I currently have more than 30 lines like that; and that …
Category: Web

Include HTML template file in wp_mail

I'm using wp_mail() to send an HTML email. But there's quite a lot of HTML code in the email, so rather than including all the code in my wp_mail() function, is it possible to have the code in a separate template and just include this template in the function? Here is what I have: <?php if ( isset( $_POST['submitted'] )) { add_filter('wp_mail_content_type',create_function('', 'return "text/html"; ')); $emailTo = '[email protected]' ; $subject = 'This is the subject'; $body = get_template_part( 'includes/my_email_template' ); …
Category: Web

Set content type to HTML for lost password email only

Is there a way to change the content type for only the password reset email? I have a custom HTML template for it, and have set wp_mail_content_type to text/html and am applying the template with a filter on retrieve_password_message. That all works fine and I get an HTML email for it, but I’m having a hard time figuring out where/how to reset wp_mail_content_type since I’m not actually calling wp_mail() anywhere. Any help would be greatly appreciated. EDIT - here’s the …
Category: Web

How to encode correclty an url with the char "&" for an email?

In a plugin I need to send an email to confirm a member registration. Inside this email HTML Content, there is a link with two parameters like this : site_url() . "/user-profile/?activate=true&token=" . $token My problem is the char "&" which prevent to send the email. I tested the function esc_url() without success. What is the WP solution ?
Category: Web

Generate Email Newsletter HTML from Posts published within a Date Range?

I would like to basically send a newsletter type email to a listy I have using a 3rd party such as MailChimp. My goal though is to be able to find or build a WordPress plugin that will allow me to get all the new Posts that are within 2 date ranges...It will then allow me to generate the HTML for Posts within that date range and then I can export the html generate to my 3rd part newsletter service …
Category: Web

Sending HTML emails via wp_mail not working properly

Task to accomplish: 1) A user types information in a form 2) Via ajax (method: POST) the form gets posted to wordpress 3) Wordpress takes the form 4) Wordpress creates an HTML-email which contains all field forms with this format: 'name':'value' 5) The email is sent to a specific email-address. Here is my function which builds up the email HTML body: function buildEmailBody() { $emailMessage = ''; $emailMessage .= "<!DOCTYPE html>"; $emailMessage .= '<html><head><meta http-equiv="Content-Type" content="text/html charset=UTF-8" /></head>'; $emailMessage .= …
Category: Web

Send an email that contains a HTML and plain text part

I am sending emails from my wordpress using SMTP Postman plugin. I have created a function in my functions.php file that creates a HTML registration email as per the below: /* Custom user registration email */ function set_bp_message_content_type() { return 'text/html'; } add_filter( 'bp_core_signup_send_validation_email_message', 'custom_buddypress_activation_message', 10, 3 ); function custom_buddypress_activation_message( $message, $user_id, $activate_url ) { add_filter( 'wp_mail_content_type', 'set_bp_message_content_type' ); $user = get_userdata( $user_id ); return ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; …
Category: Web

how to set from address according to the form input email address for wp_mail()?

I am trying to create form and send it to my e-mail address using wp_mail. my wp_mail() code is: if($_POST["submit"]) { $to="my email"; $subject ="My subject"; $sender=$_POST["sendername"]; $senderEmail=$_POST["senderEmail"]; $message=$_POST["message"]; $name_title=$_POST["name_title"]; $mailBody = "<b><span style='color: red;'>Name:</span></b> $name_title $sender\n<br/> <b>Email:</span></b> $senderEmail\n\n<br/><br/> <b>Message:</b> $message"; $mail_sent = wp_mail( $to, $subject, $mailBody ); } and for changing the from address I've added the following filters into my functions.php /* adding support for html emails*/ add_filter( 'wp_mail_content_type','wpse27856_set_content_type' ); function wpse27856_set_content_type(){ return "text/html"; } /* from address …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.