Skip to content

Instantly share code, notes, and snippets.

@peterdemartini
Created December 20, 2013 16:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterdemartini/8057641 to your computer and use it in GitHub Desktop.
Save peterdemartini/8057641 to your computer and use it in GitHub Desktop.
SugarCRM Send Email via PHP
<?php
function send_report_email($subject, $body, $emails){
require_once('include/SugarPHPMailer.php');
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = $subject;
$mail->Body = $body;
$mail->isHTML(true);
$mail->prepForOutbound();
foreach($emails as $email)
$mail->AddAddress($email);
@$mail->Send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment