[英]Email is not Delivering using Sendgrid SMTP
我正在使用 CI 庫使用 Sendgrid smtp 發送 email。
但它沒有給出任何回應,email 也沒有發送。
$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();
使用上面的代碼我發送 en email CI v3 但我沒有收到任何 email?
Twilio SendGrid 開發布道者在這里。
這里有兩件事對我來說很突出。
首先,在您設置 smtp 用戶名的位置,它應該是字符串"apikey"
(請參閱此處使用 SMTP 發送的說明)。
其次,您發送的發件人地址是“test@test.com”。 SendGrid 要求您驗證發送自的身份。 您需要 go 通過 單一發件人驗證或域身份驗證,然后使用您已驗證的 email 地址發送電子郵件。
整理好這兩位后,您的電子郵件應該會成功發送。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.