本文整理汇总了PHP中eZMail::senderText方法的典型用法代码示例。如果您正苦于以下问题:PHP eZMail::senderText方法的具体用法?PHP eZMail::senderText怎么用?PHP eZMail::senderText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZMail
的用法示例。
在下文中一共展示了eZMail::senderText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}