Guest User

Untitled

a guest
Nov 30th, 2017
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 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. }
  51.  
  52. // require_once('phpmalier.php');
  53. $mail = new SugarPHPMailer();
  54. //
  55. // $mail->setMailerForSystem();
  56. // $mail->From = $focus->settings['notify_fromaddress'];
  57. // $mail->FromName = $focus->settings['notify_fromname'];
  58. // $mail->Subject = $subject;
  59. // $mail->IsHTML(true);
  60. // $mail->Body = $body;//$html_body;
  61. // $mime_type = "application/pdf";
  62. // $mail->AddAttachment($sugar_config['upload_dir'] . $file_name.'.pdf', $file_name, 'base64', $m`enter code here`ime_type);
  63. // $mail->prepForOutbound();
  64. // $mail->AddAddress($To_email);
  65. //if (!$mail->Send()) {
  66. //$GLOBALS['log']->fatal("Email for Cases# " . $bean->name . " is not sent. Please check Email id of the contact ");
  67. // }
Add Comment
Please, Sign In to add comment