-
StackOverflow 文件
-
PHP 教程
-
傳送電子郵件
-
使用 Sendgrid 傳送純文字電子郵件
基本文字電郵
<?php
$sendgrid = new SendGrid("YOUR_SENDGRID_API_KEY");
$email = new SendGrid\Email();
$email->addTo("recipient@example.com")
->setFrom("sender@example.com")
->setSubject("Subject Text")
->setText("This is a sample basic text email using ");
$sendgrid->send($email);
新增附加收件人,CC 收件人,BCC 收件人
<?php
$sendgrid = new SendGrid("YOUR_SENDGRID_API_KEY");
$email = new SendGrid\Email();
$email->addTo("recipient@example.com")
->setFrom("sender@example.com")
->setSubject("Subject Text")
->setHtml("<html><body><p><b>This paragraph is bold.</b></p><p><i>This text is italic.</i></p></body></html>");
$personalization = new Personalization();
$email = new Email("Recepient Name", "recepient1@example.com");
$personalization->addTo($email);
$email = new Email("RecepientCC Name", "recepient2@example.com");
$personalization->addCc($email);
$email = new Email("RecepientBCC Name", "recepient3@example.com");
$personalization->addBcc($email);
$email->addPersonalization($personalization);
$sendgrid->send($email);