Create a custom translation for Themes and Plugins on WordPress
settembre 24, 2017
WordPress Plugin to set up images for Facebook’s Open Graph
settembre 28, 2017

Include HTML code in emails sent through WP Mail

Guida per Wordpress

Working with Themes and Plugins may require you to use tools like wp mail to send group email to multiple users. Definitely given the standards we are accustomed to today by getting emails, you need to include the HTML code that is correctly displayed for aesthetics of the final message.

On wordpress, in order to send formatted emails with text and html, you need to include within the functions.php the following code:

add_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' ); 
function wpdocs_set_html_mail_content_type() { return 'text/html'; }

and then before calling up the function, you need to set the mail headers like this:

$to = 'sendto@example.com';
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');

wp_mail( $to, $subject, $body, $headers );

After you have successfully entered this code you will be able to send emails using the html and css code to improve mail style.


Only for Social Generation!

Scopri di Più


RPCreative
RPCreative
Il mio nome è Riccardo Andronaco. Da sempre appassionato di PC e tecnologia in generale, mi piace essere creativo e per questo motivo ho deciso di creare un sito che possa essere utile a tutti i creativi.

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.

Pin It on Pinterest