我使用此guide作为参考,在我的Laravel应用程序的本地服务器中设置Sparkpost Mailer但是每当我尝试发送邮件时都会收到此错误。我也尝试使用与指南相同的确切设置进行复制,但我仍然得到相同的错误。但它适用于sparkpost沙盒域。
SparkPost.php第103行中的SparkPostException:{" errors":[{ "消息":"域名无效","描述":"没有发送域名 指定","代码":" 7001" }]}
我的帐户发送域名状态已经过验证,但会显示以上错误。
我的域名屏幕截图是:
我的电子邮件发送功能是:
public function sendEmail($to,$subject,$messageBody){
$httpClient = new GuzzleAdapter(new Client());
$sparky = new SparkPost($httpClient['key'=>env('SPARKPOST_SECRET')]);
$sparky->setOptions(['async' => false]);
$promise = $sparky->request('GET', 'metrics/ip-pools', [
'from' => '2014-12-01T09:00',
'to' => '2015-12-01T08:00',
'timezone' => 'America/New_York',
'limit' => '10',
]);
$promise = $sparky->transmissions->post([
'options' => [
'sandbox' => false,
'open_tracking'=> true,
'click_tracking'=> true,
'transactional'=> true,
],
'content' => [
'from' => [
'name' => 'SparkPost Team',
'email' => 'test@dskmail.com',
],
'subject' => $subject,
'html' => $messageBody,
'text' => 'Congratulations, {{name}}!! You just sent your very first mailing!',
],
'substitution_data' => ['name' => 'ashraf'],
'recipients' => [
[
'address' => [
'name' => 'Test',
'email' => $to,
],
],
],
]);
}
答案 0 :(得分:0)
我认为API密钥可能会导致该错误,但我通常只会看到来自地址的空白电子邮件。您是否向API提供了正在使用的API密钥的适当权限?
如果您从地址和API密钥中输入一个好的回复地址,这个curl命令是否适合您?
curl -X POST \
https://api.sparkpost.com/api/v1/transmissions \
-H 'Authorization: $YOUR_API_KEY' \
-H 'Cache-Control: no-cache' \
-d '{
"options": {
"open_tracking": true,
"click_tracking": true,
"transactional": true,
"sandbox": false,
},
"campaign_id": "test",
"recipients": [
{
"address": {
"email": "test@example.com",
"name": "test recipient"
},
"tags": []
}
],
"content": {
"from": {
"email": "test@dskmail.com",
"name": "SparkPost Team"
},
"subject": "My Sample Subject",
"text": "Big after Christmas sale...",
"html": "Big after Christmas sale..."
}
}
'
如果您使用Slack,您可以在此处获得更快的反馈:http://slack.sparkpost.com/