We’re excited to announce that we’ve partnered with WordPress to create a SendGrid plugin that uses SMTP or API integration to send outgoing emails from your WordPress installation. With over 60 million people harnessing the power of WordPress to build their web and blog sites as well as full featured e-commerce sites, building a SendGrid plugin to power the transactional email of these websites was a natural fit. Our integration replaces the wp_mail function included with WordPress. The SendGrid plugin is free and routes all of your WordPress emails through SendGrid, providing greater email deliverability. The SendGrid plugin for WordPress relieves developers of the cost and complexity of managing their applications’ underlying transactional email management infrastructures, freeing them to build great websites without worrying about email delivery rates, spam folders, ISP blacklists or scaling to meet high user volume. Developers can get started with a free plan that can send 200 emails per day. For developers who want to take advantage of advanced deliverability features, including their own dedicated IP address, whitelist services, ISP deliverability outreach, feedback loops and more, you can choose the Silver Plan or above. And regardless of what package you choose, you’ll always have access to SendGrid’s 24×7 live customer support. Getting Started: To have the SendGrid plugin running after you’ve activated it, go to the plugin’s settings page and set the SendGrid credentials, along with how your email will be sent – either through SMTP or API. You can also set default values for the “Name,” “Sending Address,” and the “Reply Address” so that you don’t need to set these headers every time you want to send an email from your application. Emails are tracked and automatically tagged for statistics within the SendGrid Dashboard. You can also add general tags to every email sent, as well as particular tags based on selected emails defined by your requirements. Tags help you track and report on different kinds of email. It’s helpful if you use this SendGrid account for multiple sites or properties. There are a couple levels of integration between your WordPress installation and the SendGrid plugin: The simplest option is to Install it, configure it, and the SendGrid plugin for WordPress will start sending your emails through SendGrid. We amended wp_mail() function so all email sends from WordPress should go through SendGrid. The wp_mail function is sending text emails as default, but you have an option of sending an email with HTML content. How to install the SendGrid plugin: To upload the SendGrid Plugin .ZIP file: Upload the WordPress SendGrid Plugin to the /wp-contents/plugins/ folder. Activate the plugin from the “Plugins” menu in WordPress. Navigate to “Settings” -> “SendGrid Settings” and enter your SendGrid credentials To auto install the SendGrid Plugin from the WordPress admin: Navigate to “Plugins” -> “Add New” Search for “SendGrid Plugin” and click “Install Now” for the “SendGrid Plugin” listing Activate the plugin from the “Plugins” menu in WordPress, or from the plugin installation screen. Navigate to “Settings” -> “SendGrid Settings” and enter your SendGrid credentials How to use the wp_mail() function: We amended wp_mail() function so all email sends from wordpress should go through SendGrid. You can send emails using the following function: wp_mail($to, $subject, $message, $headers = '', $attachments = array()) Where: $to – Array or comma-separated list of email addresses to send message. $subject – Email subject $message – Message contents $headers – Array or “\n” separated list of additional headers. Optional. $attachments – Array or “\n”/”,” separated list of files to attach. Optional. The wp_mail function is sending text emails as default. If you want to send an email with HTML content you have to set the content type to ‘text/html’ running add_filter('wp_mail_content_type', 'set_html_content_type'); function before the wp_mail() one. After wp_mail function you need to run remove_filter('wp_mail_content_type', 'set_html_content_type'); to remove the ‘text/html’ filter to avoid conflicts, as per this WordPress issue. Example of how to send an HTML email using different headers: $subject = 'test plugin'; $message = 'testing wordpress plugin'; $to = 'email@example.com, Address2 <firstname.lastname@example.org@>, email@example.com'; or $to = array('firstname.lastname@example.org', 'Address2 <email@example.com>', 'firstname.lastname@example.org'); $headers = array(); $headers = 'From: Me Myself <email@example.com>'; $headers = 'Cc: firstname.lastname@example.org'; $headers = 'Bcc: email@example.com'; $attachments = array(‘/tmp/img1.jpg’, ‘/tmp/img2.jpg’); add_filter(‘wp_mail_content_type’, ‘set_html_content_type’); $mail = wp_mail($to, $subject, $message, $headers, $attachments); remove_filter(‘wp_mail_content_type’, ‘set_html_content_type’); Tutorial Go to Admin Panel, section Plugins and activate the SendGrid plugin. If you want to send emails through SMTP you need to also install the ‘Swift Mailer’ plugin. After activation , a “Settings” link will appear. Go to the Settings page and provide your SendGrid credentials. On this page you can also set the default “Name,” “Sending Address,” and “Reply Address.” If you provide valid credentials, a form which can be used to send test emails will appear. Here you can test the plugin sending some emails. Header provided in the send test email form. If you click in the right corner from the top of the page on the “Help” button, a popup window with more information will appear. Now you’re all set to start experiencing increased email deliverability with SendGrid’s plugin on WordPress. Be sure to post any feedback on our plugin, so that we can add valuable enhancements to make your life easier to build the next great website!