1 回答
TA贡献1772条经验 获得超6个赞
Step1:将您的 sendgrid 库复制到第三方文件夹 step2:将以下代码添加到您的控制器方法
include APPPATH . 'third_party/sendgrid-php/sendgrid-php.php';
//$this->load->third_party('sendgrid-php');
$email = new \SendGrid\Mail\Mail();
$email->setFrom("setfrom@test.com", "testname");
$email->setSubject("MailTest");
$email->addTo('tomail@gmail.com', "User");
$email->addContent("text/plain", "subject");
$email->addContent(
"text/html",'<html><body>Message</body><html>');
$sendgrid = new \SendGrid(('sendgrid-API-KEY_HERE'));
try {
$response = $sendgrid->send($email);
print $response->statusCode() . "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: '. $e->getMessage() ."\n";
}
希望它会工作
- 1 回答
- 0 关注
- 75 浏览
添加回答
举报