1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-10 04:02:28 +01:00
polr/helper-mailsend.php.example
2014-12-28 14:52:06 -05:00

37 lines
1.2 KiB
Plaintext

<?php
/*
Polr Mailer SendGrid Implementation Example.
You will need a SendGrid account from http://sendgrid.com
and the SendGrid PHP Libraries. (instructions below)
To use this mailer, replace sgmail.php with this file.
*/
require_once 'req.php';
require_once 'sglib/sendgrid-php.php'; // Download from
// https://sendgrid-open-source.s3.amazonaws.com/sendgrid-php/sendgrid-php.zip
// place in /path/to/polr/vendor, and rename "sglib"
class sgmail {
public function sendmail($to, $subject, $message) {
$url = 'https://sendgrid.com/';
$user = '## USERNAME GOES HERE ##';
$pass = '## PASSWORD GOES HERE ##';
$p = array(
'api_user' => $user,
'api_key' => $pass,
'to' => $to,
'subject' => $subject,
'html' => $message,
'from' => '## FROM EMAIL GOES HERE ##',
);
$sendgrid = new SendGrid($p['api_user'], $p['api_key']);
$mail = new SendGrid\Email();
$mail->addTo($p['to'])->
setFrom($p['from'])->
setSubject($p['subject'])->
setText(strip_tags($p['html']))->
setHtml($p['html']);
$sendgrid->send($mail);
}
}