本文整理汇总了PHP中eZMail::setSenderText方法的典型用法代码示例。如果您正苦于以下问题:PHP eZMail::setSenderText方法的具体用法?PHP eZMail::setSenderText怎么用?PHP eZMail::setSenderText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZMail
的用法示例。
在下文中一共展示了eZMail::setSenderText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
$parameters = array();
$parameters['host'] = $ini->variable('MailSettings', 'TransportServer');
$parameters['helo'] = $ini->variable('MailSettings', 'SenderHost');
$parameters['port'] = $ini->variable('MailSettings', 'TransportPort');
$parameters['connectionType'] = $ini->variable('MailSettings', 'TransportConnectionType');
$user = $ini->variable('MailSettings', 'TransportUser');
$password = $ini->variable('MailSettings', 'TransportPassword');
if ($user and $password) {
$parameters['auth'] = true;
$parameters['user'] = $user;
$parameters['pass'] = $password;
}
/* If email sender hasn't been specified or is empty
* we substitute it with either MailSettings.EmailSender or AdminEmail.
*/
if (!$mail->senderText()) {
$emailSender = $ini->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
eZMail::extractEmail($emailSender, $emailSenderAddress, $emailSenderName);
if (!eZMail::validate($emailSenderAddress)) {
$emailSender = false;
}
if ($emailSender) {
$mail->setSenderText($emailSender);
}
}
$excludeHeaders = $ini->variable('MailSettings', 'ExcludeHeaders');
if (count($excludeHeaders) > 0) {
$mail->Mail->appendExcludeHeaders($excludeHeaders);
}
$options = new ezcMailSmtpTransportOptions();
if ($parameters['connectionType']) {
$options->connectionType = $parameters['connectionType'];
}
$smtp = new ezcMailSmtpTransport($parameters['host'], $user, $password, $parameters['port'], $options);
// If in debug mode, send to debug email address and nothing else
if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') {
$mail->Mail->to = array(new ezcMailAddress($ini->variable('MailSettings', 'DebugReceiverEmail')));
$mail->Mail->cc = array();
$mail->Mail->bcc = array();
}
// send() from ezcMailSmtpTransport doesn't return anything (it uses exceptions in case
// something goes bad)
try {
eZPerfLogger::accumulatorStart('mail_sent');
$smtp->send($mail->Mail);
eZPerfLogger::accumulatorStop('mail_sent');
} catch (ezcMailException $e) {
eZPerfLogger::accumulatorStop('mail_send');
eZDebug::writeError($e->getMessage(), __METHOD__);
return false;
}
// return true in case of no exceptions
return true;
}
示例3: sendMail
/**
*
* @param $mail
* @return unknown_type
*/
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 );
}
$this->doFakeRecepient($mail);
return $this->realTransport->sendMail($mail);
}
示例4: 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;
}
示例5: executeBeforeLastRedirect
public function executeBeforeLastRedirect($node)
{
$survey = $this->fetchFeedbackSurvey();
$surveyQuestions = $this->feedbackQuestionList();
$mailTo = $this->fetchMailTo($surveyQuestions);
if ($survey = $this->fetchFeedbackSurvey() and $survey instanceof eZSurvey and $surveyQuestions = $this->feedbackQuestionList() and $mailTo = $this->fetchMailTo($surveyQuestions) and eZMail::validate($mailTo)) {
$tpl_email = eZTemplate::factory();
$tpl_email->setVariable('intro', $this->Text2);
$tpl_email->setVariable('survey', $survey);
$tpl_email->setVariable('survey_questions', $surveyQuestions);
$tpl_email->setVariable('survey_node', $node);
$templateResult = $tpl_email->fetch('design:survey/feedbackfield_mail.tpl');
if (trim($this->Text3) != '') {
$subject = $this->Text3;
} else {
$subject = $tpl_email->variable('subject');
}
$mail = new eZMail();
$ini = eZINI::instance();
$emailSender = $ini->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
$mail->setSenderText($emailSender);
$mail->setReceiver($mailTo);
$mail->setSubject($subject);
$mail->setBody($templateResult);
if ($this->Num == 1) {
$adminReceiver = $ini->variable('MailSettings', 'AdminEmail');
$mail->addBcc($adminReceiver);
}
$mailResult = eZMailTransport::send($mail);
}
}
示例6: processViewActions
function processViewActions($objectAttribute, &$survey, &$validation)
{
$http = eZHTTPTool::instance();
$actionContinue = false;
$postNodeID = self::PREFIX_ATTRIBUTE . '_ezsurvey_node_id_' . $objectAttribute->attribute('id');
$postContentObjectAttributeID = self::PREFIX_ATTRIBUTE . '_ezsurvey_contentobjectattribute_id_' . $objectAttribute->attribute('id');
$postSurveyID = self::PREFIX_ATTRIBUTE . '_ezsurvey_id_' . $objectAttribute->attribute('id');
$continueViewActions = true;
if ($survey->attribute('one_answer') == 1) {
$user = eZUser::currentUser();
if ($user->isLoggedIn() === true) {
$contentObjectID = $objectAttribute->attribute('contentobject_id');
$contentClassAttributeID = $objectAttribute->attribute('contentclassattribute_id');
$languageCode = $objectAttribute->attribute('language_code');
$surveyID = $survey->attribute('id');
$exist = eZSurveyResult::exist($surveyID, $user->attribute('contentobject_id'), $contentObjectID, $contentClassAttributeID, $languageCode);
if ($exist === true) {
$continueViewActions = false;
}
} else {
$continueViewActions = false;
}
}
if ($continueViewActions === true) {
if ($http->hasPostVariable($postNodeID) and $http->hasPostVariable($postContentObjectAttributeID) and $http->hasPostVariable($postSurveyID)) {
$surveyID = $http->postVariable($postSurveyID);
$contentObjectAttributeID = $http->postVariable($postContentObjectAttributeID);
$nodeID = $http->postVariable($postNodeID);
$node = eZContentObjectTreeNode::fetch($nodeID);
if (get_class($node) == 'eZContentObjectTreeNode' and $node->canRead() === true) {
// verify that our attribute is included in this node.
$dataMap = $node->dataMap();
foreach ($dataMap as $attribute) {
$attributeObjectID = $attribute->attribute('id');
if ($attributeObjectID == $contentObjectAttributeID) {
$actionContinue = true;
break;
}
}
} else {
if (get_class($node) == 'eZContentObjectTreeNode') {
eZDebug::writeWarning("Not enough permissions to read node with ID: " . $nodeID . ".", 'eZSurveyType::processViewActions');
} else {
eZDebug::writeWarning("node with ID: " . $nodeID . " does not exist.", 'eZSurveyType::processViewActions');
return false;
}
}
} else {
eZDebug::writeWarning("All the postvariables {$postNodeID}, {$postContentObjectAttributeID} and {$postSurveyID} need to be supplied.", 'eZSurveyType::processViewActions');
return false;
}
$nodeID = $http->postVariable($postNodeID);
$node = eZContentObjectTreeNode::fetch($nodeID);
if ($actionContinue === true) {
$survey = eZSurvey::fetch($surveyID);
$status = $survey->validateContentObjectAttributeID($contentObjectAttributeID);
if (!$survey or !$survey->published() or !$survey->enabled() or !$survey->valid()) {
eZDebug::writeWarning('Survey is not valid', 'eZSurveyType::processViewActions');
return;
}
$params = array('prefix_attribute' => self::PREFIX_ATTRIBUTE, 'contentobjectattribute_id' => $contentObjectAttributeID);
$variableArray = $survey->processViewActions($validation, $params);
$postSurveyStoreButton = self::PREFIX_ATTRIBUTE . '_ezsurvey_store_button_' . $contentObjectAttributeID;
$user = eZUser::currentUser();
if ($survey->attribute('persistent')) {
$result = eZSurveyResult::instance($surveyID, $user->id());
} else {
$result = eZSurveyResult::instance($surveyID);
}
$result->setAttribute('user_id', $user->id());
$http = eZHTTPTool::instance();
$sessionID = $http->sessionID();
$result->setAttribute('user_session_id', $sessionID);
if ($http->hasPostVariable($postSurveyStoreButton) && $validation['error'] == false) {
$result->storeResult($params);
$postReceiverID = self::PREFIX_ATTRIBUTE . '_ezsurvey_receiver_id_' . $contentObjectAttributeID;
if ($http->hasPostVariable($postReceiverID) and $questionList = $survey->fetchQuestionList() and $postReceiverQuestionID = $http->postVariable($postReceiverID) and isset($questionList[$postReceiverQuestionID])) {
$mailTo = $questionList[$postReceiverQuestionID]->answer();
$emailSenderList = explode('_', $questionList[$postReceiverQuestionID]->attribute('text3'));
if (isset($emailSenderList[1]) and $emailSenderID = $emailSenderList[1] and is_numeric($emailSenderID) and $emailSenderID > 0 and isset($questionList[$emailSenderID]) and $senderQuestion = $questionList[$emailSenderID] and $senderQuestion->attribute('type') == 'EmailEntry' and eZMail::validate($senderQuestion->attribute('answer'))) {
$emailSender = $senderQuestion->attribute('answer');
} else {
$ini = eZINI::instance();
$emailSender = $ini->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
}
require_once 'kernel/common/template.php';
$tpl_email = templateInit();
$tpl_email->setVariable('survey', $survey);
$tpl_email->setVariable('survey_questions', $questionList);
$tpl_email->setVariable('survey_node', $node);
$templateResult = $tpl_email->fetch('design:survey/mail.tpl');
$subject = $tpl_email->variable('subject');
$mail = new eZMail();
$mail->setSenderText($emailSender);
$mail->setReceiver($mailTo);
$mail->setSubject($subject);
$mail->setBody($templateResult);
//.........这里部分代码省略.........
示例7: eZMail
$result->storeResult();
if ($http->hasPostVariable('SurveyReceiverID')) {
$surveyList = $survey->fetchQuestionList();
$mailTo = $surveyList[$http->postVariable('SurveyReceiverID')]->answer();
$tpl_email = eZTemplate::factory();
$tpl_email->setVariable('survey', $survey);
$tpl_email->setVariable('survey_questions', $surveyList);
$templateResult = $tpl_email->fetch('design:survey/mail.tpl');
$subject = $tpl_email->variable('subject');
$mail = new eZMail();
$ini = eZINI::instance();
$emailSender = $ini->variable('MailSettings', 'EmailSender');
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
$mail->setSenderText($emailSender);
$mail->setReceiver($mailTo);
$mail->setSubject($subject);
$mail->setBody($templateResult);
$mailResult = eZMailTransport::send($mail);
}
$Module->redirectTo($survey->attribute('redirect_submit'));
}
$res = eZTemplateDesignResource::instance();
$res->setKeys(array(array('survey', $surveyID)));
$tpl = eZTemplate::factory();
$tpl->setVariable('preview', false);
$tpl->setVariable('survey', $survey);
$tpl->setVariable('survey_validation', $validation);
$Result = array();
$Result['content'] = $tpl->fetch('design:survey/view.tpl');