小编TFK*_*300的帖子

Sendgrid x-smtpapi错误与'缺少目标电子邮件'

我已经设置了以下内容:

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');

$file = date('YmdHis');
$fp = fopen('/var/www/mydir/files/'.$file.'.csv', 'w');

$url = 'http://sendgrid.com/';
$user = 'myuser';
$pass = 'mypass';
$to_emails = array(
  'to' => array(
    '1@example.com','2@example.com','3@example.com'
  ),
  'category' => 'Test'
);

$fileName = $file;
$filePath = dirname(__FILE__);

$params = array(
    'api_user'  => $user,
    'api_key'   => $pass,
    'x-smtpapi' => json_encode($to_emails),
    //'to' => 'example@example.com',
    'subject'   => 'Test email',
    'html'      => '<p>Testing sendgrid mail</p>',
    'text'      => 'sent',
    'from'      => 'me@example.com',
    'files['.$file.'.csv]' => '@'.$filePath.'/files/'.$fileName.'.csv'
  );

print_r($params);

$request =  $url.'api/mail.send.json';

// Generate …
Run Code Online (Sandbox Code Playgroud)

php email curl sendgrid

0
推荐指数
1
解决办法
721
查看次数

标签 统计

curl ×1

email ×1

php ×1

sendgrid ×1