本文整理汇总了PHP中SugarPHPMailer::CreateHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarPHPMailer::CreateHeader方法的具体用法?PHP SugarPHPMailer::CreateHeader怎么用?PHP SugarPHPMailer::CreateHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarPHPMailer
的用法示例。
在下文中一共展示了SugarPHPMailer::CreateHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
//.........这里部分代码省略.........
//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) {
$mail->Encoding = 'base64';
break;
}
}
//// HANDLE EMAIL FORMAT PREFERENCE
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//// SAVE RAW MESSAGE
$mail->SetMessageType();
$raw = $mail->CreateHeader();
$raw .= $mail->CreateBody();
$this->raw_source = urlencode($raw);
//// END SAVE RAW MESSAGE
///////////////////////////////////////////////////////////////////////
$GLOBALS['log']->debug('Email sending --------------------- ');
///////////////////////////////////////////////////////////////////////
//// I18N TRANSLATION
$mail->prepForOutbound();
//// END I18N TRANSLATION
///////////////////////////////////////////////////////////////////////
if ($mail->Send()) {
///////////////////////////////////////////////////////////////////
//// INBOUND EMAIL HANDLING
// mark replied
if (!empty($_REQUEST['inbound_email_id'])) {
$ieMail = new Email();
$ieMail->retrieve($_REQUEST['inbound_email_id']);
$ieMail->status = 'replied';
$ieMail->save();
}
$GLOBALS['log']->debug(' --------------------- buh bye -- sent successful');
//// END INBOUND EMAIL HANDLING
///////////////////////////////////////////////////////////////////
return true;
}
$GLOBALS['log']->fatal("Error emailing:" . $mail->ErrorInfo);
return false;
}
示例2: 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();
}
}