Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $hook_array['before_save'][] = Array(1, 'send ', 'custom/modules/Accounts/send_email.php', 'accountSendEmail', 'send_email');
- class accountSendEmail{
- function send_email(&$bean, $event, $arguments)
- {
- if (empty($bean->fetched_row)) {
- require_once("include/phpmailer/class.phpmailer.php");
- require_once("modules/Administration/Administration.php");
- require_once("modules/EmailTemplates/EmailTemplate.php");
- $emailtemplate = new EmailTemplate();
- $emailtemplate = $emailtemplate->retrieve("email_template_id");
- $emailtemplate->parsed_entities = null;
- $temp = array();
- $template_data = $emailtemplate->parse_email_template(
- array(
- "subject" => $emailtemplate->subject,
- "body_html" => $emailtemplate->body_html,
- "body" => $emailtemplate->body
- ),
- 'Accounts',
- $bean,
- $temp
- );
- $email_body = $template_data["body_html"];
- $email_subject = $template_data["subject"];
- $admin = new Administration();
- $admin->retrieveSettings();
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->Host = $admin->settings['mail_smtpserver'];
- $mail->SMTPSecure = "ssl";
- $mail->Port = 465;
- $mail->Username = $admin->settings['mail_smtpuser'];
- $mail->Password = $admin->settings['mail_smtppass'];
- $mail->From = $admin->settings['notify_fromaddress'];
- $mail->FromName = $admin->settings['notify_fromname'];
- $mail->Subject = $email_subject;
- $mail->Body = from_html($email_body);
- $mail->IsHTML(true);
- $mail->AddAddress('your@email.address');
- if (!$mail->send()) {
- $GLOBALS['log']->info("Mailer error: " . $mail->ErrorInfo);
- $is_send = 'notsend';
- } else {
- $is_send = 'send';
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement