Skip to content

A WordPress-plugin from Webstarters

License

Notifications You must be signed in to change notification settings

webstarters/sendgrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SendGrid

A WordPress-plugin from Webstarters.

Requirements

  • WordPress 5.2
  • PHP 7.1

In addition, you must have the necessary credentials to access the SendGrid API.

Installation

You can install the package via Composer:

composer require webstarters/sendgrid

...or download the plugin as a ZIP and upload it via WP-Admin.

Configuration

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.

Usage

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.

Example

<?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;      

Debugging

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.

Security

For any security related issues, send a mail to pj+security@webstarters.dk instead of using the issue tracker.

Credits

About

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.

License

MIT License

About

A WordPress-plugin from Webstarters

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages