Dears,
Hope you are all OK.
I'm using the after add event to send an email with data inclusing the attached file.
I use authentication to send the email.
Below is my current event, I want your help to add the attachment part.
Thanks in advance.
// After record added
function AfterAdd(&$values,&$keys,$inline)
{
// Place event code here.
// Use "Add Action" button to add code snippets.
require_once "Mail.php";
$from = "XXXXXXX <xxxxx>";
$to = "XXXXXXX <xxxxx>";
$subject = "SLM - Ticket No. ".$values["tkt_id"]." Added";
$body = "Dear Mahmoud,"."\n"."Kindly be noted that ticket # ".$values["tkt_id"]." - is now added to the system"."\n"."\n"."Best Regards,"."\n"."Service Level Management System";
$host = "xxxxx";
$username = "xxxxx";
$password = "xxxxx";
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
;
} // function AfterAdd