Need to send CC in mail along with email_to_user()

Need to send CC in mail along with email_to_user()

by Amir Mustafa -
Number of replies: 0

Hello Developers,

I managed to send mail successfully through moodle default function.

Now I need to send CC and BCC using this function email_to_user()

```

$userobj            = get_complete_user_data('id',$userid);

// $targetlink         = "$CFG->wwwroot/user/profile.php?id=$userid"; // user profile in link

$targetlink         = "mailto:$userobj->email"; // mailto in link

// $targetlink         = "mailto:$userobj->email?subject=$emailsubjectcancel&body=$emailmessagecancel"; // mailto in link

$generatedFor       = '<a href = "'.$targetlink.'">' . $userobj->firstname . ' ' . $userobj->lastname . ' (' .$userobj->email . ')</a>';

$emailsubjectcancel = "Flight Plan";

$emailmessagecancel = "Hello, <br><br>";

$emailmessagecancel.= $flight_plan_message . PHP_EOL;

$emailmessagecancel.= "This flight plan was sent by <b> $generatedFor </b>.<br><br>";

$emailmessagecancel.= "<br><br><b>Get your Flight Plan <a href = '$attachment'>here</a></b>.";

// echo $emailmessagecancel;


// Trigger moodle email 

email_to_user($userobj,  'bartilona.air@gmail.com', $emailsubjectcancel, $emailmessagecancel, $emailmessagecancel);


```

Please guide me how can I proceed.

Thank you for your help in advance.


Average of ratings: -