本文整理汇总了PHP中PHPMailer::CreateHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::CreateHeader方法的具体用法?PHP PHPMailer::CreateHeader怎么用?PHP PHPMailer::CreateHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::CreateHeader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send($to, $subject, $message)
{
$sender = "no-reply@crafterous.com";
// this will be overwritten by GMail
$header = "X-Mailer: PHP/" . phpversion() . "Return-Path: {$sender}";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.crafterous.com";
$mail->SMTPAuth = true;
// $mail->SMTPSecure = "ssl";
$mail->Port = 25;
$mail->SMTPDebug = 0;
// turn it off in production
$mail->Username = "no-reply@crafterous.com";
$mail->Password = "noreplycrt2015";
$mail->From = $sender;
$mail->FromName = "Crafterous";
$mail->AddAddress($to);
$mail->IsHTML(true);
$mail->CreateHeader($header);
$mail->Subject = $subject;
$mail->Body = nl2br($message);
$mail->AltBody = nl2br($message);
// return an array with two keys: error & message
if (!$mail->Send()) {
return array('error' => true, 'message' => 'Mailer Error: ' . $mail->ErrorInfo);
} else {
return array('error' => false, 'message' => "Message sent!");
}
}
示例2:
/**
* Miscellaneous calls to improve test coverage and some small tests
*/
function test_Miscellaneous()
{
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
$this->Mail->AddCustomHeader('SomeHeader: Some Value');
$this->Mail->ClearCustomHeaders();
$this->Mail->ClearAttachments();
$this->Mail->IsHTML(false);
$this->Mail->IsSMTP();
$this->Mail->IsMail();
$this->Mail->IsSendMail();
$this->Mail->IsQmail();
$this->Mail->SetLanguage('fr');
$this->Mail->Sender = '';
$this->Mail->CreateHeader();
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
//Test pathinfo
$a = '/mnt/files/飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
$a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
}
示例3:
/**
* Miscellaneous calls to improve test coverage and some small tests
*/
function test_Miscellaneous()
{
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
$this->Mail->AddCustomHeader('SomeHeader: Some Value');
$this->Mail->ClearCustomHeaders();
$this->Mail->ClearAttachments();
$this->Mail->IsHTML(false);
$this->Mail->IsSMTP();
$this->Mail->IsMail();
$this->Mail->IsSendMail();
$this->Mail->IsQmail();
$this->Mail->SetLanguage('fr');
$this->Mail->Sender = '';
$this->Mail->CreateHeader();
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
}
示例4: CreateHeader
public function CreateHeader()
{
if ($this->Mailer == 'file') {
$this->Mailer = 'sendmail';
$headers = parent::CreateHeader();
$this->Mailer = 'file';
return $headers;
} else {
return parent::CreateHeader();
}
}
示例5: CreateHeader
public function CreateHeader()
{
$parentheader = parent::CreateHeader();
if (!empty($this->timeStamp)) {
$header = 'Received: ' . $this->timeStamp . $this->LE . $parentheader;
} else {
$header = $parentheader;
}
return $header;
}
示例6: url
echo '<div class="progBar" style="background-image: url(../img/progress/go.png);background-position:-500px 0px;"> ' . $hc_lang_news['Status0'] . '</div>';
} else {
if ($prog < 100) {
if (mysql_result($result, 0, 2) == 2) {
echo '<div class="progBar" style="background-image: url(../img/progress/pause.png);background-position:' . $position . 'px 0px;"> ' . $hc_lang_news['Status2'] . ' (' . abs(number_format($prog, 0)) . '%)</div>';
} else {
$newsletterDefault = buildUniversal($nID);
$resultS = doQuery("SELECT s.PkID, s.FirstName, s.LastName, s.Email, s.Zip, s.`Format`,\r\n\t\t\t\t\t\t\t\t(SELECT GROUP_CONCAT(c.PkID)\r\n\t\t\t\t\t\t\t\t\tFROM " . HC_TblPrefix . "subscriberscategories sc\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . HC_TblPrefix . "categories c ON (c.PkID = sc.CategoryID)\r\n\t\t\t\t\t\t\t\t\tWHERE c.IsActive = 1 AND sc.UserID = s.PkID\r\n\t\t\t\t\t\t\t\t) as Categories\r\n\t\t\t\t\t\t\t\tFROM " . HC_TblPrefix . "newssubscribers ns\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . HC_TblPrefix . "subscribers s ON (s.PkID = ns.SubscriberID)\r\n\t\t\t\t\t\t\t\tWHERE ns.NewsletterID = '" . $nID . "'\r\n\t\t\t\t\t\t\t\tLIMIT " . $hc_cfg[81]);
if (hasRows($resultS)) {
include_once HCPATH . HCINC . '/phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$host = gethostbynamel('');
$mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-Version', $hc_cfg[49]));
$mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-ID', md5($hc_cfg[19])));
$mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-IP', $host[0]));
$mail->CreateHeader();
$mail->IsHTML(true);
if ($hc_cfg[71] == 1) {
$mail->IsSMTP();
$mail->SMTPKeepAlive = true;
$mail->SMTPDebug = false;
$mail->Host = $hc_cfg[72];
$mail->Port = $hc_cfg[73];
if ($hc_cfg[77] == 1) {
$mail->SMTPAuth = true;
$mail->Username = $hc_cfg[75];
$mail->Password = base64_decode($hc_cfg[76]);
}
if ($hc_cfg[74] == 1) {
$mail->SMTPSecure = "tls";
} elseif ($hc_cfg[74] == 2) {
示例7: saveImapMessage
function saveImapMessage($data, $folder = null)
{
global $osC_Session;
require_once DIR_FS_CATALOG . 'ext/phpmailer/class.phpmailer.php';
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->CharSet = "utf-8";
$mailer->Host = $this->getSmtpHost();
$mailer->Port = $this->getSmtpPort();
$mailer->SMTPAuth = true;
$mailer->Username = $this->getSmtpUsername();
$mailer->Password = $this->getSmtpPassword();
$mailer->FromName = $data['from'];
$mailer->From = $data['sender'];
if ($data['notification'] == 'true') {
$mailer->ConfirmReadingTo = $this->getAccountEmail();
}
$mailer->Subject = $data['subject'];
$mailer->Body = $data['body'];
$mailer->AltBody = "This is the body in plain text for non-HTML mail clients";
$mailer->Priority = $data['priority'];
$mailer->IsHTML($data['content_type'] == 'html' ? true : false);
foreach ($data['to'] as $to) {
$mailer->AddAddress($to['email'], $to['name']);
}
if ($data['cc'] != null) {
foreach ($data['cc'] as $cc) {
$mailer->AddCC($cc['email'], $cc['name']);
}
}
if ($data['bcc'] != null) {
foreach ($data['bcc'] as $bcc) {
$mailer->AddBCC($bcc['email'], $bcc['name']);
}
}
$path = DIR_FS_CACHE_ADMIN . 'emails/attachments/' . $osC_Session->getID();
$osC_DirectoryListing = new osC_DirectoryListing($path);
foreach ($osC_DirectoryListing->getFiles() as $file) {
$mailer->AddAttachment($path . '/' . $file['name']);
}
$mailer->SetMessageType();
$raw_text = $mailer->CreateHeader() . "\r\n" . $mailer->CreateBody() . "\r\n";
if ($this->connectMailServer($folder)) {
if ($this->_inbox->append_message(imap::utf7_imap_encode($folder), $raw_text)) {
$this->closeMailServer();
return true;
}
}
$this->closeMailServer();
return false;
}
示例8: createHeader
public function createHeader()
{
if ($this->Mailer == 'file') {
// to have all headers in the file, like cc, bcc...
$this->Mailer = 'sendmail';
$headers = parent::CreateHeader();
$this->Mailer = 'file';
return $headers;
} else {
return parent::CreateHeader();
}
}
示例9: CreateHeader
/**
* Wraps the original CreateHeader to be able to set some headers
*/
public function CreateHeader()
{
$result = parent::CreateHeader();
preg_match_all('/Return-Path:[^\\n\\r]+[\\n\\r]/', $result, $matches);
if (count($matches[0]) > 1) {
$start = strpos($result, $matches[0][0]);
$length = strlen($matches[0][0]);
$result = substr_replace($result, '', $start, $length);
}
// mail.ru testing headers
// $result = "Date: Thu, 20 Oct 2011 18:52:09 +0300\r\nReturn-Path:andreyalek-ru@mail.ru\r\nReturn-Receipt-To:andreyalek-ru@mail.ru\r\n".
// "To:andreyalek-ru@mail.ru\r\nFrom: Andrey <august-ru@mail.ru>\r\n".
// "Reply-to: Andrey <august-ru@mail.ru>\r\nSubject: Baby Doe\r\n".
// "Message-ID: <d10f643bf3f7b3bb1303d279ff28f526@migur.woody.php.nixsolutions.com>\r\n".
// "X-Priority: 3\r\nX-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)\r\n".
// "Email-Name: Birthday of Baby Doe!(copy)\r\nSubscriber-ID: 8316\r\n".
// "MIME-Version: 1.0\r\nContent-Type: multipart/mixed;boundary=\"b1_d10f643bf3f7b3bb1303d279ff28f526\"\r\n";
// gmail
// $result = "Date: Thu, 20 Oct 2011 18:52:09 +0300\r\nReturn-Path:august-ru@mail.ru\r\nReturn-Receipt-To:august-ru@mail.ru\r\n".
// "To: Woody woody <bounced@nobodydomaintr.com>\r\nFrom: Andrey <andreyalek@gmail.com>\r\n".
// "Reply-to: Andrey <andreyalek@gmail.com>\r\nSubject: Baby Doe\r\n".
// "Message-ID: <d10f643bf3f7b3bb1303d279ff28f526@migur.woody.php.nixsolutions.com>\r\n".
// "X-Priority: 3\r\nX-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)\r\n".
// "Email-Name: Birthday of Baby Doe!(copy)\r\nSubscriber-ID: 8316\r\n".
// "MIME-Version: 1.0\r\nContent-Type: multipart/mixed;boundary=\"b1_d10f643bf3f7b3bb1303d279ff28f526\"\r\n";
return $result;
}
示例10: reMail
/**
* Master email function, use for all emails (public calendar & admin console) except newsletter mailings, wrapper for PHPMailer.
* @since 2.0.0
* @version 2.2.0
* @param string $toName name of email recipient
* @param string|array $toAddress email address of recipient OR array of recipients array($name => $address)
* @param string $subj subject line of the email
* @param string $msg message body/contents of the email
* @param string $fromName name of email sender
* @param string $fromAddress email Address of email sender
* @param array $attach Files to attach to email. (Data String, Filename, MIME Type)
* @param boolean $debug [optional] true = output PHPMailer() SMTP debug info, false = no output (Default:false)
* @return void
*/
function reMail($toName, $toAddress, $subj, $msg, $fromName = '', $fromAddress = '', $attach = NULL, $debug = false)
{
global $hc_cfg, $hc_lang_core, $hc_lang_config;
if (emailStatus() != 1) {
return -1;
}
emailStop();
if ($hc_cfg[78] == '' || $hc_cfg[79] == '') {
exit($hc_lang_core['NoEmail']);
}
include_once HCPATH . HCINC . '/phpmailer/class.phpmailer.php';
$fromName = $fromName == '' ? $hc_cfg[79] : $fromName;
$fromAddress = $fromAddress == '' ? $hc_cfg[78] : $fromAddress;
$mail = new PHPMailer();
$host = gethostbynamel('');
$mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-Version', $hc_cfg[49]));
$mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-ID', md5($hc_cfg[19])));
$mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-IP', $host[0]));
/* End Edit Restriction
*/
$mail->CreateHeader();
$mail->IsHTML(true);
$mail->CharSet = defined('CONVERT_CHRSET') && function_exists('mb_convert_encoding') ? CONVERT_CHRSET : $hc_lang_config['CharSet'];
if ($attach != NULL) {
$mail->AddStringAttachment("{$attach['0']}", "{$attach['1']}", "base64", "{$attach['2']}");
}
if (is_array($toAddress)) {
$mail->SingleToArray = $toAddress;
foreach ($toAddress as $name => $address) {
$mail->AddAddress($address, $name);
}
} else {
$mail->AddAddress($toAddress, $toName);
}
if ($hc_cfg[71] == 1) {
$mail->IsSMTP();
$mail->SMTPKeepAlive = false;
$mail->SMTPDebug = $debug;
$mail->Host = $hc_cfg[72];
$mail->Port = $hc_cfg[73];
if ($hc_cfg[77] == 1) {
$mail->SMTPAuth = true;
$mail->Username = $hc_cfg[75];
$mail->Password = base64_decode($hc_cfg[76]);
}
if ($hc_cfg[74] == 1) {
$mail->SMTPSecure = "tls";
} elseif ($hc_cfg[74] == 2) {
$mail->SMTPSecure = "ssl";
}
} else {
$mail->IsMail();
}
$mail->Sender = $hc_cfg[78];
$mail->From = $fromAddress;
$mail->FromName = cOut($fromName);
$mail->AddReplyTo($fromAddress, $fromName);
$mail->Subject = $subj;
$mail->Body = $msg;
$mail->AltBody = strip_tags(str_replace("<br />", "\n", $msg));
try {
$mail->Send();
} catch (phpmailerException $e) {
exit($e);
} catch (Exception $e) {
exit($e);
}
if ($hc_cfg[71] == 1) {
$mail->SmtpClose();
}
emailGo();
}
示例11: CreateHeader
/**
* Add Subject Prefix when creating header
* @return string
*/
public function CreateHeader()
{
$this->Subject = $this->subjectPrefix . $this->Subject;
return parent::CreateHeader();
}