i am trying to send mail with CC address and without TO address.
My code is bellow.
JavaScript
x
$mail_param['msg'] = "demo";
$mail_param['link'] = "xyz.com";
$email = '';
$name = "demo user";
$cc = 'abc@gmail.com';
Mail::send('view_template', $mail_param, function ($message) use ($email, $name, $cc) {
if ($cc != '') {
$message->to($email, $name)->bcc($cc)->subject('Test Mail');
} elseif ($email != '') {
$message->to($email, $name)->subject('Test Mail');
}
});
I am trying above code and get the bellow error.
local.ERROR: Address in mailbox given [] does not comply with RFC 2822, 3.6.2.
Advertisement
Answer
You Can try with array arguments.
JavaScript
$mail_param['msg'] = "demo";
$mail_param['link'] = "xyz.com";
$email = array();
$name = "demo user";
$cc = array('abc@gmail.com');
Mail::send('view_template', $mail_param, function ($message) use ($email, $name, $cc)
{
if (!empty($cc)) {
$message->to($email, $name)->bcc($cc)->subject('Test Mail');
} elseif (!empty($email)) {
$message->to($email, $name)->subject('Test Mail');
}
});