【发布时间】:2017-02-09 15:41:02
【问题描述】:
我已将网站从简单托管移至 Azure Cloud,但现在我的电子邮件无法发送。我已经安装了 SendGrid 并保存了用户名和密码。然后我编辑了我的contact.php 文件。 contact.php的代码是:
<?php
$url = 'https://api.sendgrid.com/';
$user = 'username that I saved';
$pass = 'password that I created';
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => 'mymailaddress@mail.com',
'subject' => 'testing from curl',
'html' => 'testing body',
'text' => 'testing body',
'from' => 'anna@contoso.com',
);
$request = $url.'api/mail.send.json';
// Generate curl request
$session = curl_init($request);
// Tell curl to use HTTP POST
curl_setopt ($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
// print everything out
print_r($response);
?>
我保存了它并通过我的浏览器访问它,但没有任何显示。我检查了我的电子邮件收件箱(还有垃圾邮件),但那里什么也没有。
【问题讨论】: