WordPress invia email transazionali per il reset delle password, la registrazione di nuovi utenti, le conferme di acquisto e le notifiche dei plugin. Le email di default in testo semplice svolgono il loro lavoro, ma appaiono poco professionali rispetto alle email HTML dei servizi moderni. Personalizzare le email di WordPress con modelli HTML migliora la percezione del marchio e l'esperienza utente.
Questa guida spiega come creare modelli email HTML professionali per le email transazionali di WordPress.
Hook di personalizzazione delle email
WordPress fornisce diversi hook per personalizzare le email. Il filtro wp_mail_from modifica l'indirizzo email del mittente. Il filtro wp_mail_from_name modifica il nome del mittente. Il filtro wp_mail_content_type modifica il tipo di contenuto in text/html per le email HTML. Usali nel tuo plugin o tema per impostare un branding email coerente.
Set the content type to text/html before sending HTML emails. Remember to reset it to text/plain after your email is sent out to avoid breaking other email functionality.
HTML Email Structure
HTML emails use table-based layouts for compatibility across email clients. Structure your email with an outer table for the background and a centered inner table for the content. Use inline CSS styles — email clients strip style tags from the head section. Test emails in Gmail, Outlook, Apple Mail, and mobile clients.
Include a preheader — a short text that appears after the subject line in most email clients. Use this for a summary or call-to-action that encourages opening the email. Keep your email focused on a single primary action or message.
Email Template Classes
Create a base email template class that handles the common HTML structure — header, body, footer, and styling. Extend this class for specific email types. The base class sets up the HTML skeleton, Doctype, charset, and responsive styles. Each email type provides its own content for the body section.
{ "original": "Use placeholder variables for dynamic content — {{site_name}}, {{user_name}}, {{action_url}}, {{expiration_date}}. Replace these with actual values before sending. Keep your design simple and focused on readability.", "translation": "Utilizza variabili segnaposto per il contenuto dinamico — {{site_name}}, {{user_name}}, {{action_url}}, {{expiration_date}}. Sostituiscile con valori reali prima dell'invio. Mantieni il design semplice e incentrato sulla leggibilità." }
Multipart Emails
Send multipart emails that include both HTML and plain-text versions. Email clients display the HTML version if supported, and fall back to plain text for clients that don’t render HTML. This ensures your emails are readable everywhere.
Generate the plain-text version by stripping HTML tags from your email content and simplifying links to show URLs explicitly. The PHPMailer class that WordPress uses supports multipart emails natively.
{"Testing and Deliverability": "Test e consegnabilità"}
Test your email templates before sending them to users. Use Litmus or Email on Acid for comprehensive email rendering previews across 70+ email clients. Test with your actual email delivery service — Postmark, SendGrid, or Amazon SES — to ensure DKIM, SPF, and DMARC pass.
Monitora le metriche di deliverability delle tue email. Tieni traccia dei tassi di rimbalzo, dei tassi di apertura e dei reclami di spam tramite il tuo servizio email. Se i tassi di rimbalzo superano il 5%, rivedi la qualità della tua lista email e le tue pratiche di invio.
Il punto fondamentale
I modelli email HTML professionali migliorano la percezione del tuo brand e il coinvolgimento delle email. Usa gli hook email di WordPress per personalizzare le informazioni del mittente e il tipo di contenuto. Crea modelli email basati su tabelle con stili inline. Crea un sistema di classi di modelli per design email manutenibili. Invia email multipart per la massima compatibilità. Testa accuratamente su tutti i client email e monitora le metriche di deliverability.




