<?php
if (isset($_POST['send']))
{
$email = $_POST['email'];
$subject = $_POST['subject'];
$body = $_POST['message'];
$data = array(
"personalizations" => array(
array(
"to" => array(
array(
"email" => $email,
"name" => $name
)
)
)
) ,
"from" => array(
"email" => $sender
) ,
"subject" => $subject,
"content" => array(
array(
"type" => "text/html",
"value" => $body
)
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sendgrid.com/v3/mail/send");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
}
?>
我正在使用 Sendgrid API 使用 PHP 发送电子邮件我可以一次发送到一封电子邮件,但我需要将$email
变量作为大量电子邮件传递
array(
"email" => $email,
"name" => $name
)
$email
变量将参数设置为电子邮件集合示例:$email="abc@mail.com,info@abc.com,def@gmail.com"
我该怎么做?