Hello Friends,
I have managed to successfully send email to user. Now the issue is I have tried various ways to send email with attachment. 5th and 6th parameter sends the email attachment. But it is not working:
Code:
$trimval = trim($val);
$sql = "SELECT id FROM {user} WHERE email = '$trimval'";
$useridSql = $DB->get_record_sql($sql);
// $userid = $useridSql->id;
$userid = 15;
if($userid == '') { continue; }
/*$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>.";*/
$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);
email_to_user($userobj, 'bartilona.air@gmail.com', $emailsubjectcancel, $emailmessagecancel, $emailmessagecancel, 'path1/path2', 'test.php');
Please guide me how to proceed. I am stuck in this attachments process. Please guide me I am stuck in this step.