本文整理汇总了PHP中SugarPHPMailer::IsHTML方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarPHPMailer::IsHTML方法的具体用法?PHP SugarPHPMailer::IsHTML怎么用?PHP SugarPHPMailer::IsHTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarPHPMailer
的用法示例。
在下文中一共展示了SugarPHPMailer::IsHTML方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendSugarPHPMail
function sendSugarPHPMail($tos, $subject, $body)
{
require_once 'include/SugarPHPMailer.php';
require_once 'modules/Administration/Administration.php';
global $current_user;
$mail = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
if ($admin->settings['mail_sendtype'] == "SMTP") {
$mail->Host = $admin->settings['mail_smtpserver'];
$mail->Port = $admin->settings['mail_smtpport'];
if ($admin->settings['mail_smtpauth_req']) {
$mail->SMTPAuth = TRUE;
$mail->Username = $admin->settings['mail_smtpuser'];
$mail->Password = $admin->settings['mail_smtppass'];
}
$mail->Mailer = "smtp";
$mail->SMTPKeepAlive = true;
} else {
$mail->mailer = 'sendmail';
}
$mail->IsSMTP();
// send via SMTP
if ($admin->settings['mail_smtpssl'] == '2') {
$mail->SMTPSecure = "tls";
} elseif ($admin->settings['mail_smtpssl'] == '1') {
$mail->SMTPSecure = "ssl";
}
$mail->CharSet = 'UTF-8';
$mail->From = $admin->settings['notify_fromaddress'];
$mail->FromName = $admin->settings['notify_fromname'];
$mail->ContentType = "text/html";
//"text/plain"
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
foreach ($tos as $name => $address) {
$mail->AddAddress("{$address}", "{$name}");
}
if (!$mail->send()) {
$GLOBALS['log']->info("sendSugarPHPMail - Mailer error: " . $mail->ErrorInfo);
return false;
} else {
return true;
}
}
示例2: sendEmailForPassword
/**
* Send new password or link to user
*
* @param string $templateId Id of email template
* @param array $additionalData additional params: link, url, password
* @return array status: true|false, message: error message, if status = false and message = '' it means that send method has returned false
*/
public function sendEmailForPassword($templateId, array $additionalData = array())
{
global $sugar_config, $current_user;
$mod_strings = return_module_language('', 'Users');
$result = array('status' => false, 'message' => '');
$emailTemp = new EmailTemplate();
$emailTemp->disable_row_level_security = true;
if ($emailTemp->retrieve($templateId) == '') {
$result['message'] = $mod_strings['LBL_EMAIL_TEMPLATE_MISSING'];
return $result;
}
//replace instance variables in email templates
$htmlBody = $emailTemp->body_html;
$body = $emailTemp->body;
if (isset($additionalData['link']) && $additionalData['link'] == true) {
$htmlBody = str_replace('$contact_user_link_guid', $additionalData['url'], $htmlBody);
$body = str_replace('$contact_user_link_guid', $additionalData['url'], $body);
} else {
$htmlBody = str_replace('$contact_user_user_hash', $additionalData['password'], $htmlBody);
$body = str_replace('$contact_user_user_hash', $additionalData['password'], $body);
}
// Bug 36833 - Add replacing of special value $instance_url
$htmlBody = str_replace('$config_site_url', $sugar_config['site_url'], $htmlBody);
$body = str_replace('$config_site_url', $sugar_config['site_url'], $body);
$htmlBody = str_replace('$contact_user_user_name', $this->user_name, $htmlBody);
$htmlBody = str_replace('$contact_user_pwd_last_changed', TimeDate::getInstance()->nowDb(), $htmlBody);
$body = str_replace('$contact_user_user_name', $this->user_name, $body);
$body = str_replace('$contact_user_pwd_last_changed', TimeDate::getInstance()->nowDb(), $body);
$emailTemp->body_html = $htmlBody;
$emailTemp->body = $body;
$itemail = $this->emailAddress->getPrimaryAddress($this);
//retrieve IT Admin Email
//_ppd( $emailTemp->body_html);
//retrieve email defaults
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
require_once 'include/SugarPHPMailer.php';
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
//$mail->IsHTML(true);
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->ClearAllRecipients();
$mail->ClearReplyTos();
$mail->Subject = from_html($emailTemp->subject);
if ($emailTemp->text_only != 1) {
$mail->IsHTML(true);
$mail->Body = from_html($emailTemp->body_html);
$mail->AltBody = from_html($emailTemp->body);
} else {
$mail->Body_html = from_html($emailTemp->body_html);
$mail->Body = from_html($emailTemp->body);
}
if ($mail->Body == '' && $current_user->is_admin) {
global $app_strings;
$result['message'] = $app_strings['LBL_EMAIL_TEMPLATE_EDIT_PLAIN_TEXT'];
return $result;
}
if ($mail->Mailer == 'smtp' && $mail->Host == '' && $current_user->is_admin) {
$result['message'] = $mod_strings['ERR_SERVER_SMTP_EMPTY'];
return $result;
}
$mail->prepForOutbound();
$hasRecipients = false;
if (!empty($itemail)) {
if ($hasRecipients) {
$mail->AddBCC($itemail);
} else {
$mail->AddAddress($itemail);
}
$hasRecipients = true;
}
if ($hasRecipients) {
$result['status'] = @$mail->Send();
}
if ($result['status'] == true) {
$emailObj->team_id = 1;
$emailObj->to_addrs = '';
$emailObj->type = 'archived';
$emailObj->deleted = '0';
$emailObj->name = $mail->Subject;
$emailObj->description = $mail->Body;
$emailObj->description_html = null;
$emailObj->from_addr = $mail->From;
$emailObj->parent_type = 'User';
$emailObj->date_sent = TimeDate::getInstance()->nowDb();
$emailObj->modified_user_id = '1';
$emailObj->created_by = '1';
$emailObj->status = 'sent';
$emailObj->save();
if (!isset($additionalData['link']) || $additionalData['link'] == false) {
$user_hash = strtolower(md5($additionalData['password']));
$this->setPreference('loginexpiration', '0');
//.........这里部分代码省略.........
示例3: in
/* Query database to get case aging */
$query = 'select c.case_number,c.name,concat("http://dcmaster.mydatacom.com/index.php?module=Cases&action=DetailView&record=",c.id) as link from cases as c where c.id not in (select distinct case_id from projects_cases) and c.account_id is null and c.status="New" and c.deleted=0;';
$db = DBManagerFactory::getInstance();
$result = $db->query($query, true, 'Case Unassigned Query Failed');
/* Create email bodies to send */
$linecount = 0;
$emailbody = "The following cases are currently unassigned:<br /><br />";
while (($row = $db->fetchByAssoc($result)) != null) {
$emailbody .= "<a href='" . $row['link'] . "'>" . $row['case_number'] . " - " . $row['name'] . " </a><br />";
$linecount++;
}
if ($linecount > 0) {
/* Send out emails */
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->ClearAllRecipients();
$mail->ClearReplyTos();
$mail->Subject = "Unassigned Case Report";
$mail->IsHTML(true);
$mail->Body = $emailbody;
$mail->AltBody = $emailbody;
$mail->prepForOutbound();
$mail->AddAddress('noc@getdatacom.com');
$mail->Send();
/* Clean up shop */
$mail->SMTPClose();
}
示例4: sendCreationEmail
private function sendCreationEmail(aCase $bean, $contact)
{
if (!isAOPEnabled()) {
return;
}
require_once "include/SugarPHPMailer.php";
$mailer = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
$mailer->prepForOutbound();
$mailer->setMailerForSystem();
$email_template = new EmailTemplate();
$aop_config = $this->getAOPConfig();
$email_template = $email_template->retrieve($aop_config['case_creation_email_template_id']);
if (!$aop_config['case_creation_email_template_id'] || !$email_template) {
$GLOBALS['log']->warn("CaseUpdatesHook: sendCreationEmail template is empty");
return false;
}
$emailSettings = getPortalEmailSettings();
$text = $this->populateTemplate($email_template, $bean, $contact);
$mailer->Subject = $text['subject'];
$mailer->Body = $text['body'];
$mailer->IsHTML(true);
$mailer->AltBody = $text['body_alt'];
$mailer->From = $emailSettings['from_address'];
$mailer->FromName = $emailSettings['from_name'];
$email = $contact->emailAddress->getPrimaryAddress($contact);
if (empty($email) && !empty($contact->email1)) {
$email = $contact->email1;
}
$mailer->AddAddress($email);
if (!$mailer->Send()) {
$GLOBALS['log']->info("CaseUpdatesHook: Could not send email: " . $mailer->ErrorInfo);
return false;
} else {
$this->logEmail($email, $mailer, $bean->id);
return true;
}
}
示例5: run
public function run($data)
{
global $sugar_config, $timedate;
$bean = BeanFactory::getBean('AOR_Scheduled_Reports', $data);
$report = $bean->get_linked_beans('aor_report', 'AOR_Reports');
if ($report) {
$report = $report[0];
} else {
return false;
}
$html = "<h1>{$report->name}</h1>" . $report->build_group_report();
$html .= <<<EOF
<style>
h1{
color: black;
}
.list
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;font-size: 12px;
background: #fff;margin: 45px;width: 480px;border-collapse: collapse;text-align: left;
}
.list th
{
font-size: 14px;
font-weight: normal;
color: black;
padding: 10px 8px;
border-bottom: 2px solid black};
}
.list td
{
padding: 9px 8px 0px 8px;
}
</style>
EOF;
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
/*$result = $report->db->query($report->build_report_query());
$reportData = array();
while($row = $report->db->fetchByAssoc($result, false))
{
$reportData[] = $row;
}
$fields = $report->getReportFields();
foreach($report->get_linked_beans('aor_charts','AOR_Charts') as $chart){
$image = $chart->buildChartImage($reportData,$fields,false);
$mail->AddStringEmbeddedImage($image,$chart->id,$chart->name.".png",'base64','image/png');
$html .= "<img src='cid:{$chart->id}'>";
}*/
$mail->setMailerForSystem();
$mail->IsHTML(true);
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = from_html($bean->name);
$mail->Body = $html;
$mail->prepForOutbound();
$success = true;
$emails = $bean->get_email_recipients();
foreach ($emails as $email_address) {
$mail->ClearAddresses();
$mail->AddAddress($email_address);
$success = $mail->Send() && $success;
}
$bean->last_run = $timedate->getNow()->asDb(false);
$bean->save();
return true;
}
示例6: send
//.........这里部分代码省略.........
$filename = str_replace($mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ', '', $filename);
// cn: bug 9233 attachment filenames need to be translated into the destination charset.
$filename = $locale->translateCharset($filename, 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
//is attachment in our list of bad files extensions? If so, append .txt to file location
//get position of last "." in file name
$file_ext_beg = strrpos($file_location, ".");
$file_ext = "";
//get file extension
if ($file_ext_beg > 0) {
$file_ext = substr($file_location, $file_ext_beg + 1);
}
//check to see if this is a file with extension located in "badext"
foreach ($sugar_config['upload_badext'] as $badExt) {
if (strtolower($file_ext) == strtolower($badExt)) {
//if found, then append with .txt to filename and break out of lookup
//this will make sure that the file goes out with right extension, but is stored
//as a text in db.
$file_location = $file_location . ".txt";
break;
// no need to look for more
}
}
$mail->AddAttachment($file_location, $filename, 'base64', $mime_type);
}
//// END ATTACHMENTS
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//// HANDLE EMAIL FORMAT PREFERENCE
// the if() below is HIGHLY dependent on the Javascript unchecking the Send HTML Email box
// HTML email
if (isset($_REQUEST['setEditor']) && $_REQUEST['setEditor'] == 1 && trim($_REQUEST['description_html']) != '' || trim($this->description_html) != '') {
// wp: if body is html, then insert new lines at 996 characters. no effect on client side
// due to RFC 2822 which limits email lines to 998
$mail->IsHTML(true);
$body = from_html(wordwrap($this->description_html, 996));
$mail->Body = $body;
// if alternative body is defined, use that, else, striptags the HTML part
if (trim($this->description) == '') {
$plainText = from_html($this->description_html);
$plainText = strip_tags(br2nl($plainText));
//$plainText = $locale->translateCharset($plainText, 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
$mail->AltBody = $plainText;
$this->description = $plainText;
} else {
$mail->AltBody = wordwrap(from_html($this->description), 996);
}
// cn: bug 9709 - html email sent accidentally
// handle signatures fubar'ing the type
$sigs = $current_user->getDefaultSignature();
$htmlSig = trim(str_replace(" ", "", strip_tags(from_html($sigs['signature_html']))));
$htmlBody = trim(str_replace(" ", "", strip_tags(from_html($this->description_html))));
if ($htmlSig == $htmlBody) {
// found just a sig. ignore it.
$this->description_html = '';
$mail->IsHTML(false);
$mail->Body = wordwrap(from_html($this->description, 996));
}
} else {
// plain text only
$this->description_html = '';
$mail->IsHTML(false);
$mail->Body = wordwrap(from_html($this->description, 996));
}
// wp: if plain text version has lines greater than 998, use base64 encoding
foreach (explode("\n", $mail->ContentType == "text/html" ? $mail->AltBody : $mail->Body) as $line) {
if (strlen($line) > 998) {
示例7: handleBodyInHTMLformat
/**
* Retrieve function from handlebody() to unit test easily
* @param SugarPHPMailer $mail SugarPHPMailer instance
* @return formatted $mail body
*/
function handleBodyInHTMLformat($mail)
{
global $sugar_config;
// wp: if body is html, then insert new lines at 996 characters. no effect on client side
// due to RFC 2822 which limits email lines to 998
$mail->IsHTML(true);
$body = from_html(wordwrap($this->description_html, 996));
$mail->Body = $body;
// cn: bug 9725
// new plan is to use the selected type (html or plain) to fill the other
$plainText = from_html($this->description_html);
$plainText = strip_tags(br2nl($plainText));
$mail->AltBody = $plainText;
$this->description = $plainText;
$mail->replaceImageByRegex("(?:{$sugar_config['site_url']})?/?cache/images/", sugar_cached("images/"));
//Replace any embeded images using the secure entryPoint for src url.
$mail->replaceImageByRegex("(?:{$sugar_config['site_url']})?/?index.php[?]entryPoint=download&(?:amp;)?[^\"]+?id=", "upload://", true);
$mail->Body = from_html($mail->Body);
}
示例8: enviarEmail
public static function enviarEmail($asunto, $mensaje, $direcciones, $from)
{
require_once "include/SugarPHPMailer.php";
$mailer = new SugarPHPMailer();
$mailer->Subject = $asunto;
$mailer->From = $from['from'];
$mailer->FromName = $from['from_name'];
foreach ($direcciones as $email) {
$mailer->AddAddress($email);
}
$mailer->Body = $mensaje;
$mailer->prepForOutbound();
$mailer->setMailerForSystem();
$mailer->IsHTML(true);
if ($mailer->Send()) {
return true;
} else {
$GLOBALS['log']->info("No se ha podido enviar el correo electronico: " . $mailer->ErrorInfo);
return false;
}
}
示例9: sendEmail
private function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null)
{
$GLOBALS['log']->info("AOPCaseUpdates: sendEmail called");
require_once "include/SugarPHPMailer.php";
$mailer = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
$mailer->prepForOutbound();
$mailer->setMailerForSystem();
$signatureHTML = "";
if ($signature && array_key_exists("signature_html", $signature)) {
$signatureHTML = from_html($signature['signature_html']);
}
$signaturePlain = "";
if ($signature && array_key_exists("signature", $signature)) {
$signaturePlain = $signature['signature'];
}
$emailSettings = getPortalEmailSettings();
$GLOBALS['log']->info("AOPCaseUpdates: sendEmail email portal settings are " . print_r($emailSettings, true));
$text = $this->populateTemplate($template, $addDelimiter, $contactId);
$mailer->Subject = $text['subject'];
$mailer->Body = $text['body'] . $signatureHTML;
$mailer->IsHTML(true);
$mailer->AltBody = $text['body_alt'] . $signaturePlain;
$mailer->From = $emailSettings['from_address'];
$mailer->FromName = $emailSettings['from_name'];
foreach ($emails as $email) {
$mailer->AddAddress($email);
}
if ($mailer->Send()) {
require_once 'modules/Emails/Email.php';
$emailObj = new Email();
$emailObj->to_addrs = implode(",", $emails);
$emailObj->type = 'out';
$emailObj->deleted = '0';
$emailObj->name = $mailer->Subject;
$emailObj->description = $mailer->AltBody;
$emailObj->description_html = $mailer->Body;
$emailObj->from_addr = $mailer->From;
if ($caseId) {
$emailObj->parent_type = "Cases";
$emailObj->parent_id = $caseId;
}
$emailObj->date_sent = TimeDate::getInstance()->nowDb();
$emailObj->modified_user_id = '1';
$emailObj->created_by = '1';
$emailObj->status = 'sent';
$emailObj->save();
} else {
$GLOBALS['log']->info("AOPCaseUpdates: Could not send email: " . $mailer->ErrorInfo);
return false;
}
return true;
}
示例10: emails
function generate_email()
{
global $mod_strings;
global $current_user;
global $sugar_config;
global $locale;
require_once 'include/utils.php';
$query = 'SELECT name';
$query .= ' FROM emails';
$query .= " WHERE deleted=0";
$query .= " AND name='{$this->pnum}-Estimate'";
$result = $this->db->query($query, true, " Error filling in additional detail fields: ");
$n = $this->db->getRowCount($result);
if ($n == 0) {
$queryname = 'SELECT user_name';
$queryname .= ' FROM users';
$queryname .= " WHERE deleted=0";
$queryname .= " AND id='{$this->assigned_user_id}'";
$result_name = $this->db->query($queryname, true, " Error filling in additional detail fields: ");
$username = $this->db->fetchByAssoc($result_name);
$to_addrs_names = $username['user_name'];
$queryemail = 'SELECT email1';
$queryemail .= ' FROM users';
$queryemail .= " WHERE deleted=0";
$queryemail .= " AND id='{$this->assigned_user_id}'";
$result_email = $this->db->query($queryemail, true, " Error filling in additional detail fields: ");
$useremail = $this->db->fetchByAssoc($result_email);
$to_addrs_emails = $useremail['email1'];
$id = create_guid();
$from_addr = $current_user->name;
$from_name = $current_user->email1;
$name = $this->pnum . '-Estimate';
$description = $this->pnum . ' is waiting for estimate';
$query2 = "INSERT into emails (id, assigned_user_id, created_by, name, status, to_addrs_names, to_addrs_emails, from_addr, from_name, description, deleted, type, intent) ";
$query2 .= " VALUES ('{$id}', '{$this->assigned_user_id}', '{$current_user->id}', '{$name}', 'sent', '{$to_addrs_names}', '{$to_addrs_emails}', '{$from_addr}', '{$from_name}', '{$description}', '0', 'out', 'pick') ";
$this->db->query($query2, true, " Error filling in additional detail fields: ");
$mail = new SugarPHPMailer();
$mail->AddAddress($to_addrs_emails, $to_addrs_names);
$mail->Mailer = "sendmail";
// FROM ADDRESS
$mail->From = $from_addr;
// FROM NAME
$mail->FromName = $from_name;
$mail->Sender = $mail->From;
/* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
$mail->AddReplyTo($mail->From, $mail->FromName);
$encoding = version_compare(phpversion(), '5.0', '>=') ? 'UTF-8' : 'ISO-8859-1';
$mail->Subject = html_entity_decode($name, ENT_QUOTES, $encoding);
///////////////////////////////////////////////////////////////////////
//// HANDLE EMAIL FORMAT PREFERENCE
// the if() below is HIGHLY dependent on the Javascript unchecking the Send HTML Email box
// HTML email
// plain text only
$description_html = '';
$mail->IsHTML(false);
$mail->Body = wordwrap(from_html($description, 996));
// wp: if plain text version has lines greater than 998, use base64 encoding
foreach (explode("\n", $mail->ContentType == "text/html" ? $mail->AltBody : $mail->Body) as $line) {
if (strlen($line) > 998) {
$mail->Encoding = 'base64';
break;
}
}
//// HANDLE EMAIL FORMAT PREFERENCE
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//// SAVE RAW MESSAGE
$mail->SetMessageType();
$raw = $mail->CreateHeader();
$raw .= $mail->CreateBody();
$raw_source = urlencode($raw);
//// END SAVE RAW MESSAGE
///////////////////////////////////////////////////////////////////////
$GLOBALS['log']->debug('Email sending --------------------- ');
///////////////////////////////////////////////////////////////////////
//// I18N TRANSLATION
$mail->prepForOutbound();
//// END I18N TRANSLATION
///////////////////////////////////////////////////////////////////////
$mail->Send();
}
}
示例11: run
public function run($data)
{
global $timedate;
$bean = BeanFactory::getBean('AOR_Scheduled_Reports', $data);
$report = $bean->get_linked_beans('aor_report', 'AOR_Reports');
if ($report) {
$report = $report[0];
} else {
return false;
}
$html = "<h1>{$report->name}</h1>" . $report->build_group_report();
$html .= <<<EOF
<style>
h1{
color: black;
}
.list
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;font-size: 12px;
background: #fff;margin: 45px;width: 480px;border-collapse: collapse;text-align: left;
}
.list th
{
font-size: 14px;
font-weight: normal;
color: black;
padding: 10px 8px;
border-bottom: 2px solid black};
}
.list td
{
padding: 9px 8px 0px 8px;
}
</style>
EOF;
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->IsHTML(true);
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = from_html($bean->name);
$mail->Body = $html;
$mail->prepForOutbound();
$success = true;
$emails = $bean->get_email_recipients();
foreach ($emails as $email_address) {
$mail->ClearAddresses();
$mail->AddAddress($email_address);
$success = $mail->Send() && $success;
}
$bean->last_run = $timedate->getNow()->asDb(false);
$bean->save();
return true;
}
示例12: sendSugarPHPMail
/**
* Created by iluxovi4 - Убирайте везде эту подпись
* Protected by SugarTalk.ru greshdrtju
=======
*/
function sendSugarPHPMail($tos, $subject, $body, $attach = "", $nameToSend = "", $assigned_user_id, $type)
{
require_once 'include/SugarPHPMailer.php';
require_once 'modules/Administration/Administration.php';
global $current_user;
$mail = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
$user = new User();
if ($type == 'Realty') {
$user_id = $assigned_user_id;
$user->retrieve($user_id);
$oe = new OutboundEmail();
$userSettings = $oe->getUserMailerSettings($user);
if ($admin->settings['mail_sendtype'] == "SMTP") {
$mail->Host = $admin->settings['mail_smtpserver'];
$mail->Port = $admin->settings['mail_smtpport'];
if ($admin->settings['mail_smtpauth_req']) {
$mail->SMTPAuth = TRUE;
$mail->Username = $admin->settings['mail_smtpuser'];
$mail->Password = $admin->settings['mail_smtppass'];
}
$mail->Mailer = "smtp";
$mail->SMTPKeepAlive = true;
} else {
$mail->mailer = 'sendmail';
}
$mail->IsSMTP();
// send via SMTP
if ($admin->settings['mail_smtpssl'] == '2') {
$mail->SMTPSecure = "tls";
} elseif ($admin->settings['mail_smtpssl'] == '1') {
$mail->SMTPSecure = "ssl";
}
//$mail->Body = $body."<br/> <b style='color: red;'><strong> Важно! </strong> Ответ присылайте на почту: </b>".$userSettings->mail_smtpuser;
$mail->Body = $body;
$mail->From = $admin->settings['notify_fromaddress'];
} elseif ($type == 'Contacts' or $type == 'Accounts') {
$user_id = $assigned_user_id;
$user->retrieve($user_id);
$oe = new OutboundEmail();
$userSettings = $oe->getUserMailerSettings($user);
if ($userSettings->mail_sendtype == "SMTP") {
$mail->Host = $admin->settings['mail_smtpserver'];
$mail->Port = $admin->settings['mail_smtpport'];
if ($userSettings->mail_smtpauth_req) {
$mail->SMTPAuth = TRUE;
$mail->Username = $userSettings->mail_smtpuser;
$mail->Password = $userSettings->mail_smtppass;
}
$mail->Mailer = "smtp";
$mail->SMTPKeepAlive = true;
} else {
$mail->mailer = 'sendmail';
}
$mail->IsSMTP();
// send via SMTP
if ($admin->settings['mail_smtpssl'] == '2') {
$mail->SMTPSecure = "tls";
} elseif ($admin->settings['mail_smtpssl'] == '1') {
$mail->SMTPSecure = "ssl";
}
$mail->Body = $body;
$mail->From = $user->email1;
}
//$user->retrieve();
$mail->CharSet = 'UTF-8';
$mail->FromName = $admin->settings['notify_fromname'];
$mail->ContentType = "text/html";
//"text/plain"
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->AddAttachment($attach, $nameToSend);
foreach ($tos as $name => $address) {
$mail->AddAddress("{$address}", "{$name}");
}
if (!$mail->send()) {
$GLOBALS['log']->info("sendSugarPHPMail - Mailer error: " . $mail->ErrorInfo);
return false;
} else {
return true;
}
}