本文整理汇总了PHP中Pagekit\Application::mailer方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::mailer方法的具体用法?PHP Application::mailer怎么用?PHP Application::mailer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagekit\Application
的用法示例。
在下文中一共展示了Application::mailer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requestAction
/**
* @Request({"email": "string"})
*/
public function requestAction($email)
{
try {
if (App::user()->isAuthenticated()) {
return App::redirect();
}
if (!App::csrf()->validate()) {
throw new Exception(__('Invalid token. Please try again.'));
}
if (empty($email)) {
throw new Exception(__('Enter a valid email address.'));
}
if (!($user = User::findByEmail($email))) {
throw new Exception(__('Unknown email address.'));
}
if ($user->isBlocked()) {
throw new Exception(__('Your account has not been activated or is blocked.'));
}
$user->activation = App::get('auth.random')->generateString(32);
$url = App::url('@user/resetpassword/confirm', ['user' => $user->username, 'key' => $user->activation], 0);
try {
$mail = App::mailer()->create();
$mail->setTo($user->email)->setSubject(__('Reset password for %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/reset.php', compact('user', 'url', 'mail')), 'text/html')->send();
} catch (\Exception $e) {
throw new Exception(__('Unable to send confirmation link.'));
}
$user->save();
return ['message' => __('Check your email for the confirmation link.')];
} catch (Exception $e) {
App::abort(400, $e->getMessage());
}
}
示例2: sendMail
/**
* @return MailHelper
*/
public function sendMail()
{
if (!($adminMail = $this->submission->form->get('submitEmail'))) {
return $this;
}
$user_email = $this->submission->email ?: false;
$mailSubject = $this->replaceString($this->submission->form->get('email_subject'));
$mailBody = $this->replaceString($this->submission->form->get('email_body'));
$mailBody = App::content()->applyPlugins($mailBody, ['submission' => $this->submission, 'markdown' => $this->submission->form->get('email_body_markdown')]);
try {
/** @var Message $mail */
$mail = App::mailer()->create();
if ($user_email && $this->submission->form->get('use_replyto', 0)) {
$mail->setReplyTo($user_email);
}
$mail->setTo($adminMail)->setSubject($mailSubject)->setBody(App::view('bixie/formmaker/mails/template.php', compact('mailBody')), 'text/html')->send();
if ($user_email) {
$mail = App::mailer()->create();
$mail->setTo($user_email)->setSubject($mailSubject)->setBody(App::view('bixie/formmaker/mails/template.php', compact('mailBody')), 'text/html')->send();
}
} catch (\Exception $e) {
throw new Exception(__('Unable to send confirmation mail.'));
}
return $this;
}
示例3: emailAction
/**
* Note: If the mailer is accessed prior to this controller action, this will possibly test the wrong mailer
*
* @Request({"option": "array"}, csrf=true)
*/
public function emailAction($option = [])
{
try {
$config = Arr::merge(App::module('system/mail')->config(), $option);
$response['success'] = (bool) App::mailer()->create(__('Test email!'), __('Testemail'), $config['from_address'])->send();
$response['message'] = $response['success'] ? __('Mail successfully sent!') : __('Mail delivery failed!');
} catch (\Exception $e) {
$response = ['success' => false, 'message' => sprintf(__('Mail delivery failed! (%s)'), $e->getMessage())];
}
return $response;
}
示例4: sendMail
/**
* @return string
*/
public function sendMail()
{
if (!($adminMail = $this->submission->form->get('submitEmail'))) {
return '';
}
$userMail = '';
$mailSubject = $this->replaceString($this->submission->form->get('email_subject'));
$mailBody = $this->replaceString($this->submission->form->get('email_body'));
$mailBody = App::content()->applyPlugins($mailBody, ['submission' => $this->submission, 'markdown' => $this->submission->form->get('email_body_markdown')]);
try {
$mail = App::mailer()->create();
$mail->setTo($adminMail)->setSubject($mailSubject)->setBody(App::view('formmaker:views/mails/template.php', compact('mailBody')), 'text/html')->send();
if ($this->submission->email) {
$mail = App::mailer()->create();
$mail->setTo($this->submission->email)->setSubject($mailSubject)->setBody(App::view('formmaker:views/mails/template.php', compact('mailBody')), 'text/html')->send();
}
} catch (\Exception $e) {
throw new Exception(__('Unable to send confirmation mail.'));
}
return $userMail;
}
示例5: sendApproveMail
protected function sendApproveMail($user)
{
try {
$mail = App::mailer()->create();
$mail->setTo(App::module('mail')->config('from_address'))->setSubject(__('Approve an account at %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/approve.php', compact('user', 'mail')), 'text/html')->send();
} catch (\Exception $e) {
}
}