Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. $hook_array['before_save'][] = Array(1, 'send ', 'custom/modules/Accounts/send_email.php', 'accountSendEmail', 'send_email');
  2.  
  3. class accountSendEmail{
  4. function send_email(&$bean, $event, $arguments)
  5. {
  6. if (empty($bean->fetched_row)) {
  7. require_once("include/phpmailer/class.phpmailer.php");
  8. require_once("modules/Administration/Administration.php");
  9. require_once("modules/EmailTemplates/EmailTemplate.php");
  10. $emailtemplate = new EmailTemplate();
  11. $emailtemplate = $emailtemplate->retrieve("email_template_id");
  12. $emailtemplate->parsed_entities = null;
  13. $temp = array();
  14. $template_data = $emailtemplate->parse_email_template(
  15. array(
  16. "subject" => $emailtemplate->subject,
  17. "body_html" => $emailtemplate->body_html,
  18. "body" => $emailtemplate->body
  19. ),
  20. 'Accounts',
  21. $bean,
  22. $temp
  23. );
  24. $email_body = $template_data["body_html"];
  25. $email_subject = $template_data["subject"];
  26. $admin = new Administration();
  27. $admin->retrieveSettings();
  28. $mail = new PHPMailer();
  29. $mail->IsSMTP();
  30. $mail->SMTPAuth = true;
  31. $mail->Host = $admin->settings['mail_smtpserver'];
  32. $mail->SMTPSecure = "ssl";
  33. $mail->Port = 465;
  34. $mail->Username = $admin->settings['mail_smtpuser'];
  35. $mail->Password = $admin->settings['mail_smtppass'];
  36. $mail->From = $admin->settings['notify_fromaddress'];
  37. $mail->FromName = $admin->settings['notify_fromname'];
  38. $mail->Subject = $email_subject;
  39. $mail->Body = from_html($email_body);
  40. $mail->IsHTML(true);
  41. $mail->AddAddress('your@email.address');
  42. if (!$mail->send()) {
  43. $GLOBALS['log']->info("Mailer error: " . $mail->ErrorInfo);
  44. $is_send = 'notsend';
  45. } else {
  46. $is_send = 'send';
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement