如何在PHP中使用SendGrid将BCC,CC和文件附件用于电子邮件?

时间:2018-08-08 14:41:38

标签: sendgrid

我正在使用以下代码发送电子邮件:

function sendEmail(){            
    $from = new SendGrid\Email('Support', 'support@xxxxxxxxxxxx.com');
    $subject = "this is testing mail with attachment!";
    $to = new SendGrid\Email("Raj", "sahu.rajkaran4@gmail.com");
    $content = new SendGrid\Content("text/html", 'Hi, This is body mail.');
    $mail = new SendGrid\Mail($from, $subject, $to, $content);

    $att1 = new SendGrid\Attachment();
    $att1->setContent(base64_encode(file_get_contents('file_url_HERE')));
    $att1->setType("application/pdf");
    $att1->setFilename("test.pdf");
    $att1->setDisposition("attachment");
    $mail->addAttachment( $att1 );

    $sg = new \SendGrid('xuuuxxxxxxxxxxxxxxxxxx');
    $response = $sg->client->mail()->send()->post($mail);
    return $response->statusCode();
}

没有BCC和CC,代码可以正常工作。在这里如何使用BCC和CC?

0 个答案:

没有答案