A WordPress-plugin from Webstarters.
- WordPress 5.2
- PHP 7.1
In addition, you must have the necessary credentials to access the SendGrid API.
You can install the package via Composer:
composer require webstarters/sendgrid
...or download the plugin as a ZIP and upload it via WP-Admin.
You must set WS_SENDGRID_API_KEY
in your wp-config.php
with your SendGrid API Key.
You may set a default SendGrid Template ID for all mails via WS_SENDGRID_DEFAULT_TEMPLATE_ID
.
This plugin overwrites wp_mail
to send via SendGrid.
You can also send mail via the new sendgrid_mail
method, which extends wp_mail, but adds the possibility of specifying template data and ID.
<?php
$to = 'Peter Jørgensen <pj@webstarters.dk>';
$subject = 'Hello';
$message = 'Hello World!';
$headers = [
'Cc: Peter Jørgensen <pj@webstarters.dk>',
'Bcc: Peter Jørgensen <pj@webstarters.dk>',
'Reply-To: Peter Jørgensen <pj@webstarters.dk>',
];
$attachments = [
'https://via.placeholder.com/1280x720',
];
$templateData = [
'foo' => 'bar',
];
$templateId = 'd-cf81460749c34cd697916aa4760f552c';
$success = sendgrid_mail($to, $subject, $message, $headers, $attachments, $templateData, $templateId);
echo $success;
To begin, enable WP_DEBUG
and WP_DEBUG_LOG
in the wp_config.php
file.
Remember to disable WP_DEBUG_DISPLAY
if the website is in a production environment.
For any security related issues, send a mail to pj+security@webstarters.dk instead of using the issue tracker.
We are a Digital agency focusing on efficient sparring, efficient process and efficient digital solutions. Just that, pure and precise effect.
When we say Webstarters, that's exactly what we are. And what we do.
Learn more at Webstarters.dk digital marketing bureau.