无法使用sendGrid API发送邮件

时间:2019-03-20 10:22:55

标签: php codeigniter sendgrid

$sendgrid = new SendGrid($sendgrid_username, $sendgrid_password, array("turn_off_ssl_verification" => true));
    $email = new \SendGrid\Mail\Mail(); 
    // $email    = new SendGrid\Email();
    $email->addTo($to)->
    setfrom("info.kickingworld@gmail.com")->
    setFromName("Kicking World")->
    addSubstitution("[%first_name | Customer%]", array($fist_name))->
    addSubstitution("[%first_name | Default Value%]", array($last_name))->
    addSubstitution("[Sender_Name]", array("Kicking World"))->
    addSubstitution("[Sender_Address]", array())->
    addSubstitution("[Sender_City]", array())->
    addSubstitution("[Sender_State]", array())->
    addSubstitution("[Sender_Zip]", array())->
    addSubstitution("<%asm_group_unsubscribe_raw_url%>", array())->
    addSubstitution("[Weblink]", array())->
    addHeader('X-Sent-Using', 'SendGrid-API')->
    addHeader('X-Transport', 'web')->
    setSubject('cancelation')->
    setHTML('Body')->
    setTemplateId($template);
    $response = $sendgrid->send($email);

我正在尝试使用PHP使用sendgrid邮件API发送邮件,但出现错误。

Message: Call to a member function setfrom() on null

我是新来的,这是我的第一篇文章。需要帮助!

0 个答案:

没有答案