本文整理汇总了PHP中EmailMessage::addTo方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailMessage::addTo方法的具体用法?PHP EmailMessage::addTo怎么用?PHP EmailMessage::addTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailMessage
的用法示例。
在下文中一共展示了EmailMessage::addTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyUser
/**
* Notifies a user of a new comment in an article.
*
* @param notification The ArticleNotification object.
* @param userInfo An UserInfo object with information about the user (we
* mainly will need the email address!)
* @param subject Subject of the message that will be sent to the user.
* @param body Message that will be sent to the user.
* @param charset the encoding that will be used in the message (it should be based
* on the locale of the blog who is sending this message) It defaults to iso-8859-1
* @return Returns true if the user was correctly notified or false otherwise.
*/
function notifyUser($notification, $userInfo, $subject, $body, $charset = 'iso-8859-1')
{
//print( "sending notification to ".$userInfo->getEmail()."<br/>");
$message = new EmailMessage();
$message->setFrom($this->_config->getValue("post_notification_source_address"));
$message->addTo($userInfo->getEmail());
$message->setSubject("pLog Notification system");
$message->setBody($body);
$message->setCharset($charset);
$service = new EmailService();
return $service->sendMessage($message);
}
示例2: sendNotificationEmail
function sendNotificationEmail($userInfo)
{
// if everything went fine, we can now send the confirmation email
// only if the user specified a valid email address
if ($userInfo->getEmail() != "") {
// build an email message
$message = new EmailMessage();
$message->setBody($this->_notificationText);
$message->setSubject("pLog Notification");
$message->addTo($userInfo->getEmail());
$message->setFrom($this->_userInfo->getEmail());
// and finally send it
$emailService = new EmailService();
$emailService->sendMessage($message);
}
return true;
}
示例3: sendResetEmail
/**
* sends the email with the request
* @private
*/
function sendResetEmail($userInfo, $url)
{
// prepare the template
$templateService = new TemplateService();
$template = $templateService->Template("resetpasswordemail", "summary");
$template->assign("locale", $this->_locale);
$template->assign("reseturl", $url);
// render it and keep its contents
$emailBody = $template->fetch();
$message = new EmailMessage();
$config =& Config::getConfig();
$message->setFrom($config->getValue("post_notification_source_address"));
$message->addTo($userInfo->getEmail());
$message->setSubject("pLog Password Reset Request");
$message->setBody($emailBody);
$service = new EmailService();
return $service->sendMessage($message);
}
示例4: perform
function perform()
{
// extract the data
$recipients = $this->_request->getValue("messageRecipient");
$recipientsCc = $this->_request->getValue("messageCc");
$recipientsBcc = $this->_request->getValue("messageBcc");
$text = $this->_request->getValue("messageText");
$subject = $this->_request->getValue("messageSubject");
// check that we've got either a 'to','cc' or 'bcc'
if ($recipients == "" && $recipientsCc == "" && $recipientsBcc == "") {
// force an error
$this->_view = new MailCentreSendMessageView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message"));
$this->_form->setFieldValidationStatus("messageRecipient", false);
$this->setCommonData(true);
}
// pre-process some of the data
$recipients = str_replace(" ", "", $recipients);
$recipientsCc = str_replace(" ", "", $recipientsCc);
$recipientsBcc = str_replace(" ", "", $recipientsBcc);
// and get the list of recipients
$listUnexpanded = explode(",", $recipients);
$list = array();
foreach ($listUnexpanded as $recipient) {
$result = $this->_expandRecipients($recipient);
$list = array_merge($list, $result);
}
$listCcUnexpanded = explode(",", $recipientsCc);
$listCc = array();
foreach ($listCcUnexpanded as $recipient) {
$result = $this->_expandRecipients($recipient);
$listCc = array_merge($listCc, $result);
}
$listBccUnexpanded = explode(",", $recipientsBcc);
$listBcc = array();
foreach ($listBccUnexpanded as $recipient) {
$result = $this->_expandRecipients($recipient);
$listBcc = array_merge($listBcc, $result);
}
// create a mail message that includes all the recipients
$message = new EmailMessage();
$val = new EmailValidator();
$totalTo = 0;
$totalCc = 0;
$totalBcc = 0;
foreach ($list as $to) {
// add each one of the recipients
if ($val->validate($to)) {
$message->addTo($to);
$totalTo++;
}
}
foreach ($listCc as $cc) {
// add each one of the recipients
if ($val->validate($cc)) {
$message->addCc($cc);
$totalCc++;
}
}
foreach ($listBcc as $bcc) {
// add each one of the recipients
if ($val->validate($bcc)) {
$message->addBcc($bcc);
$totalBcc++;
}
}
// check that we are really sending the message to somebody
if ($totalTo == 0 && $totalCc == 0 && $totalBcc == 0) {
// force an error
$this->_view = new MailCentreSendMessageView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message"));
$this->_form->setFieldValidationStatus("messageRecipient", false);
$this->setCommonData(true);
}
// and now set the subject and body...
$message->setSubject($subject);
$message->setBody($text);
// set the encoding based on the current blog settings
$locale =& $this->_blogInfo->getLocale();
$message->setCharset($locale->getCharset());
// and the "from" address
$config =& Config::getConfig();
$from = $config->getValue("post_notification_source_address");
$message->setFrom($from);
// now send the message
$service = new EmailService();
if (!$service->sendMessage($message)) {
// if something went wrong, go back to the previous view
$this->_view = new MailCentreSendMessageView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("mailcentre_error_sending_message"));
// show the view and keep the data that was in the form
$this->setCommonData(true);
}
$recipients = implode(",", $list);
$recipientsCc = implode(",", $listCc);
$recipientsBcc = implode(",", $listBcc);
// if everything went ok, create our own MailMessage object and save it to the database
$mailMessage = new MailMessage($subject, $text, $recipients, $recipientsCc, $recipientsBcc);
$mailMessages = new MailMessages();
$mailMessages->addMessage($mailMessage);
//.........这里部分代码省略.........