未使用SendGrid SMTP传递电子邮件 [英] Email is not Delivering using Sendgrid SMTP

查看:34
本文介绍了未使用SendGrid SMTP传递电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CI库通过SendGrid SMTP发送电子邮件。

但它没有任何响应,也没有发送电子邮件。

$this->load->library('email');
$config['protocol']  = 'smtp';
$config['smtp_host'] = 'smtp.sendgrid.net';
$config['smtp_user'] = 'api key name';
$config['smtp_pass'] = 'api key';
$config['smtp_port'] = '587';
$config['smtp_keepalive'] = 'TRUE';

$this->email->initialize($config);
$this->email->from('test@test.com', FROM_NAME);

$this->email->to($email);
extract($arr_var);
$sub=addslashes($row['subject']);
eval("$subject= "$sub";");
$body=addslashes($row['message']);
eval("$message= "$body";");
if ($subject!='') {
    $this->email->subject(stripslashes($subject));
} else {
    $this->email->subject($row['subject'].' - '.$this->config->item('app_title'));
}
    $this->email->message($message);
    $bool=$this->email->send();

使用上面的代码,我正在发送电子邮件CI v3,但是我没有收到任何电子邮件吗?

推荐答案

Twilio SendGrid Developer布道者点击此处。

这里有两件事对我来说很突出。

首先,在设置SMTP用户名的位置,它应该是字符串"apikey"(请参阅the instructions for sending with SMTP here)。

其次,您要发送的发件人地址是";test@test.com";。SendGrid要求您verify the identity you send from。您需要通过Single Sender VerificationDomain Authentication,然后使用您已验证的电子邮件地址发送电子邮件。

一旦您整理好这两个部分,您的电子邮件就应该可以成功发送了。

这篇关于未使用SendGrid SMTP传递电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆