本文整理汇总了PHP中eZMail::body方法的典型用法代码示例。如果您正苦于以下问题:PHP eZMail::body方法的具体用法?PHP eZMail::body怎么用?PHP eZMail::body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZMail
的用法示例。
在下文中一共展示了eZMail::body方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
function sendMail(eZMail $mail)
{
$ini = eZINI::instance();
$sendmailOptions = '';
$emailFrom = $mail->sender();
$emailSender = $emailFrom['email'];
if (!$emailSender || count($emailSender) <= 0) {
$emailSender = $ini->variable('MailSettings', 'EmailSender');
}
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
if (!eZMail::validate($emailSender)) {
$emailSender = false;
}
$isSafeMode = ini_get('safe_mode');
if ($isSafeMode and $emailSender and $mail->sender() == false) {
$mail->setSenderText($emailSender);
}
$filename = time() . '-' . mt_rand() . '.mail';
$data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $mail->headerText() . "\n" . $mail->body());
$returnedValue = eZFile::create($filename, 'var/log/mail', $data);
if ($returnedValue === false) {
eZDebug::writeError('An error occurred writing the e-mail file in var/log/mail', __METHOD__);
}
return $returnedValue;
}
示例2: sendMail
function sendMail(eZMail $mail)
{
$ini = eZINI::instance();
$sendmailOptions = '';
$emailFrom = $mail->sender();
$emailSender = isset($emailFrom['email']) ? $emailFrom['email'] : false;
if (!$emailSender || count($emailSender) <= 0) {
$emailSender = $ini->variable('MailSettings', 'EmailSender');
}
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
if (!eZMail::validate($emailSender)) {
$emailSender = false;
}
$isSafeMode = ini_get('safe_mode') != 0;
$sendmailOptionsArray = $ini->variable('MailSettings', 'SendmailOptions');
if (is_array($sendmailOptionsArray)) {
$sendmailOptions = implode(' ', $sendmailOptionsArray);
} elseif (!is_string($sendmailOptionsArray)) {
$sendmailOptions = $sendmailOptionsArray;
}
if (!$isSafeMode and $emailSender) {
$sendmailOptions .= ' -f' . $emailSender;
}
if ($isSafeMode and $emailSender and $mail->sender() == false) {
$mail->setSenderText($emailSender);
}
if (function_exists('mail')) {
$message = $mail->body();
$sys = eZSys::instance();
$excludeHeaders = array('Subject');
// If not Windows PHP mail() implementation, we can not specify a To: header in the $additional_headers parameter,
// because then there will be 2 To: headers in the resulting e-mail.
// However, we can use "undisclosed-recipients:;" in $to.
if ($sys->osType() != 'win32') {
$excludeHeaders[] = 'To';
$receiverEmailText = count($mail->ReceiverElements) > 0 ? $mail->receiverEmailText() : 'undisclosed-recipients:;';
} else {
$receiverEmailText = $mail->receiverEmailText();
}
// If in debug mode, send to debug email address and nothing else
if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') {
$receiverEmailText = $ini->variable('MailSettings', 'DebugReceiverEmail');
$excludeHeaders[] = 'To';
$excludeHeaders[] = 'Cc';
$excludeHeaders[] = 'Bcc';
}
$extraHeaders = $mail->headerText(array('exclude-headers' => $excludeHeaders));
$returnedValue = mail($receiverEmailText, $mail->subject(), $message, $extraHeaders, $sendmailOptions);
if ($returnedValue === false) {
eZDebug::writeError('An error occurred while sending e-mail. Check the Sendmail error message for further information (usually in /var/log/messages)', __METHOD__);
}
return $returnedValue;
} else {
eZDebug::writeWarning("Unable to send mail: 'mail' function is not compiled into PHP.", __METHOD__);
}
return false;
}
示例3: testRegressionBodyString
public function testRegressionBodyString()
{
$mail = new eZMail();
$mail->setBody(__FUNCTION__);
$ezpResult = $mail->body();
$ezcResult = $mail->Mail->body;
$ezpExpected = __FUNCTION__;
$ezcExpected = new ezcMailText(__FUNCTION__, 'utf-8');
$this->assertEquals($ezpExpected, $ezpResult);
$this->assertEquals($ezcExpected, $ezcResult);
}
示例4: doFakeRecepient
/**
* Remplace le destinataire du mail par le "faut" destinataire,
* supprime tous les cc et bcc et les rajoute en entête du corp du message
*
* @param eZMail $mail L'objet mail à traiter
*/
private function doFakeRecepient (eZMail $mail)
{
$fakeHead = array();
$fakeHead[]='To: ' . $mail->receiverText();
foreach ($mail->ccReceiverTextList() as $aCcReceiver)
{
$fakeHead[] = 'Cc: ' . $aCcReceiver;
}
foreach ($mail->bccReceiverTextList() as $aBccReceiver)
{
$fakeHead[] = 'Bcc: ' . $aBccReceiver;
}
$mail->setReceiver($this->fakeReceiver);
$mail->setCcElements(array());
$mail->setBccElements(array());
$origBody = $mail->body();
$newBody = '------' . __CLASS__ . '------' . "\n";
$newBody .= ':: Original parameters ::' . "\n\n";
$newBody .= implode("\n", $fakeHead) . "\n";
$newBody .= '------' . __CLASS__ . '------' . "\n\n";
$newBody .= $origBody;
$mail->setBody($newBody);
}