I am trying to send mail only to Bcc but unable to send. Code given below is working fine with To and Bcc but when i try to send only with Bcc it fails. I tried passing empty string with To but didnt work. I am using mailgun php API.
function send_mail($email,$subject,$msg,$bcc)
{
$api_key="";
$domain ="";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'api:'.$api_key);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v2/'.$domain.'/messages');
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'from' => 'Example <[email protected]>',
'to' => $email,
'bcc' => $bcc,
'subject' => $subject,
'html' => $msg,
'o:tracking' => true));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
send_mail($email, $subject, $msg, $bcc);
Message-ID is a unique identifier for a digital message, most commonly a globally unique identifier used in email and Usenet newsgroups. Message-IDs are required to have a specific format which is a subset of an email address and be globally unique. No two different messages must ever have the same Message-ID.
5,000 messages/month are included. There is a limit of 300 messages per day on the included sandbox domain. Data retention for Logs and the Events API is 1 day.
TextMagic, also a Mailgun customer, allows you to send notifications, alerts, reminders, confirmations and SMS marketing campaign messages to your customers, staff members and suppliers. On average, TextMagic customers are sending over 2.5M text messages around the world each month.
You may not send mail only using bcc. There is a trick I use in which I make the from
and to
the same address (something like [email protected]
) and then fill up the bcc
slot with whatever I need.
You may send mail using mailing lists that does not require you to expose other email addresses. https://documentation.mailgun.com/en/latest/api-mailinglists.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With