本文整理汇总了PHP中Email::forge方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::forge方法的具体用法?PHP Email::forge怎么用?PHP Email::forge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::forge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_testemail
public function action_testemail()
{
// Create an instance
if (Auth::check()) {
$data['user_link'] = 'logout';
$email = Auth::get_screen_name();
$data['email'] = $email;
} else {
$data['user_link'] = 'login';
}
$email = Email::forge();
// Set the from address
$email->from('no-reply@pscms.local', 'pscms.local');
// Set the to address
$email->to('blueshift9@gmail.com', 'You');
// Set a subject
$email->subject('This is the subject');
// Set multiple to addresses
/*$email->to(array(
'example@mail.com',
'another@mail.com' => 'With a Name',
));*/
// And set the body.
$email->body('This is my message');
try {
$email->send();
} catch (\EmailValidationFailedException $e) {
// The validation failed
} catch (\EmailSendingFailedException $e) {
// The driver could not send the email
exit('driver cant send mail');
}
}
示例2: sendReservedEMail
public static function sendReservedEMail($id)
{
$reservation = Model_Lessontime::find($id);
// for teacher
$url = Uri::base() . "teachers/top";
date_default_timezone_set(Config::get("timezone.timezone")[$reservation->teacher->timezone]);
$body = View::forge("email/teachers/reserved", ["url" => $url]);
$body->set("name", $reservation->teacher->firstname);
$body->set("reservation", $reservation);
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to($reservation->teacher->email);
$sendmail->subject("Lesson Booking Confirmation / Game-bootcamp");
$sendmail->html_body(htmlspecialchars_decode($body));
$sendmail->send();
// for student
$url = Uri::base() . "students/top";
date_default_timezone_set(Config::get("timezone.timezone")[$reservation->student->timezone]);
$body = View::forge("email/students/reserved", ["url" => $url]);
$body->set("name", $reservation->student->firstname);
$body->set("reservation", $reservation);
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to($reservation->student->email);
$sendmail->subject("Lesson Booking Confirmation / Game-bootcamp");
$sendmail->html_body(htmlspecialchars_decode($body));
$sendmail->send();
}
示例3: send_email_to_group
/**
* Send email to group of admin users
*
* @param type $group_name
* @param type $subject
* @param type $view
* @param type $email_data
* @param type $attachment = Attache a file
* @param type $theme = theme to load views from
* @return boolean
* @throws \Exception
*/
public static function send_email_to_group($group_name, $subject, $view, $email_data, $attachment = false)
{
\Config::load('auto_response_emails', 'auto_response_emails', true);
$emails = \Config::get('auto_response_emails.' . $group_name . '_emails', false);
if ($emails == false) {
$emails = \Config::get('auto_response_emails.default_emails', false);
}
$bcc = \Config::get('auto_response_emails.bcc');
$email = \Email::forge();
$email->cc($emails);
if ($bcc) {
$email->bcc($bcc);
}
$email->subject($subject);
$email->from(\Config::get('auto_response_emails.autoresponder_from_email'), \Config::get('site_title'));
if ($attachment) {
$email->attach($attachment);
}
$emailView = \Theme::instance()->view('views/' . $view)->set('email_data', $email_data, false);
$email->html_body($emailView);
try {
$email->send();
} catch (\Exception $e) {
if (\Fuel::$env == 'development') {
throw new \Exception($e->getMessage());
} else {
return false;
}
}
return true;
}
示例4: action_index
public function action_index()
{
$this->template = View::forge("teachers/template");
$this->template->auth_status = false;
$this->template->title = "Forgotpassword";
// login
if (Input::post("email", null) !== null and Security::check_token()) {
$email = Input::post('email', null);
$user = Model_User::find("first", ["where" => [["email", $email]]]);
if ($user != null) {
$token = Model_Forgotpasswordtoken::forge();
$token->user_id = $user->id;
$token->token = sha1("asadsada23424{$user->email}" . time());
$token->save();
$url = Uri::base() . "teachers/forgotpassword/form/{$token->token}";
$body = View::forge("email/forgotpassword", ["url" => $url]);
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to($email);
$sendmail->subject("forgot password");
$sendmail->html_body(htmlspecialchars_decode($body));
$sendmail->send();
}
$view = View::forge("teachers/forgotpassword/sent");
$this->template->content = $view;
} else {
$view = View::forge("teachers/forgotpassword/index");
$this->template->content = $view;
}
}
示例5: _send_instructions
/**
* Sends the instructions to a user's email address.
*
* @return bool
*/
private static function _send_instructions($name, Model_User $user)
{
$config_key = null;
switch ($name) {
case 'confirmation':
$config_key = 'confirmable';
break;
case 'reset_password':
$config_key = 'recoverable';
break;
case 'unlock':
$config_key = 'lockable';
break;
default:
throw new \InvalidArgumentException("Invalid instruction: {$name}");
}
$mail = \Email::forge();
$mail->from(\Config::get('email.defaults.from.email'), \Config::get('email.defaults.from.name'));
$mail->to($user->email);
$mail->subject(__("warden.mailer.subject.{$name}"));
$token_name = "{$name}_token";
$mail->html_body(\View::forge("warden/mailer/{$name}_instructions", array('username' => $user->username, 'uri' => \Uri::create(':url/:token', array('url' => rtrim(\Config::get("warden.{$config_key}.url"), '/'), 'token' => $user->{$token_name})))));
$mail->priority(\Email::P_HIGH);
try {
return $mail->send();
} catch (\EmailSendingFailedException $ex) {
logger(\Fuel::L_ERROR, "Warden\\Mailer failed to send {$name} instructions.");
return false;
}
}
示例6: sendMailByParams
/**
* ユーザーにメールを送信
*
* @para $name メールの識別子 $params 差し込むデータ $to 送り先(指定しなければ langの値を使用) $options Fuel準拠のEmailオプション
* @access protected
* @return bool
* @author kobayasi
* @author shimma
*/
public function sendMailByParams($name, $params = array(), $to = null, $options = null)
{
Lang::load("email/{$name}");
$email = Email::forge();
$email->from(Lang::get('from'), Lang::get('from_name'));
$email->subject($this->renderTemplate(Lang::get('subject'), $params, false));
$email->body($this->renderTemplate(Lang::get('body'), $params));
if (!$to) {
$to = Lang::get('email');
}
$email->to($to);
if (Lang::get('bcc') != '') {
$email->bcc(Lang::get('bcc'));
}
if (!empty($options)) {
foreach ($options as $option => $value) {
if (empty($value)) {
continue;
}
switch ($option) {
case 'bcc':
$email->bcc($value);
break;
case 'reply_to':
$email->reply_to($value);
break;
case 'subject':
$email->subject($value);
break;
}
}
}
return $email->send();
}
示例7: create_user
public function create_user($userdata)
{
$password = \Arr::get($userdata, 'password', null);
$email = \Arr::get($userdata, 'email', null);
if (is_null($password) || is_null($email)) {
Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, $email);
throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid'));
}
$user = Auth_Driver::get_core_user($email);
$security = new Model_User_Security();
//Generate a salt
$security->salt = Hasher::instance()->hash(\Date::time(), Random::instance()->random());
$security->password = Hasher::instance()->hash($password, $security->salt);
if (\Config::get('ethanol.activate_emails', false)) {
$keyLength = \Config::get('ethanol.activation_key_length');
$security->activation_hash = Random::instance()->random($keyLength);
$user->activated = 0;
//Send email
\Package::load('email');
//Build an array of data that can be passed to the email template
$emailData = array('email' => $user->email, 'activation_path' => \Str::tr(\Config::get('ethanol.activation_path'), array('key' => $security->activation_hash)));
$email = \Email::forge()->from(\Config::get('ethanol.activation_email_from'))->to($user->email, $user->username)->subject(\Config::get('ethanol.activation_email_subject'))->html_body(\View::forge('ethanol/activation_email', $emailData))->send();
} else {
$user->activated = 1;
$security->activation_hash = '';
}
$user->security = $security;
$user->save();
$user->clean_security();
return $user;
}
示例8: action_submit
public function action_submit()
{
if (!Security::check_token()) {
Response::redirect('_404_');
}
if (Session::get_flash('name')) {
$contact = Model_Contact::forge();
$contact->title = Session::get_flash("title");
$contact->body = Session::get_flash("body");
$body = View::forge("email/contact");
$body->set("name", Session::get_flash('name'));
$body->set("email", Session::get_flash('email'));
$body->set("body", Session::get_flash('body'));
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to(Config::get("statics.info_email"));
$sendmail->subject("We got contact/ Game-bootcamp");
$sendmail->body($body);
$sendmail->send();
}
$this->template->title = "Contact";
$this->template->sub = "How can we help you?";
$view = View::forge("contacts/send");
$this->template->content = $view;
}
示例9: action_send
public function action_send()
{
$data['token_key'] = Config::get('security.csrf_token_key');
$data['token'] = Security::fetch_token();
$error = array();
if (Security::check_token()) {
$val = Validation::forge();
$val->add_field('username', 'ユーザID', 'required|max_length[9]');
$val->add_field('mail', 'メールアドレス', 'required|valid_email');
if ($val->run()) {
//受信データの整理
$username = Input::post('username');
$email = Input::post('mail');
//登録ユーザの有無の確認
$user_count = Model_Users::query()->where('username', $username)->where('email', $email)->count();
//該当ユーザがいれば
if ($user_count > 0) {
//Authのインスタンス化
$auth = Auth::instance();
//新しいパスワードの自動発行
$repass = $auth->reset_password($username);
//送信データの整理
$data['fullname'] = Model_Users::query()->select('fullname')->where('username', $username)->get();
$data['repass'] = $repass;
$data['email'] = $email;
$data['anchor'] = 'login';
$body = View::forge('login/email/autorepass', $data);
//Eメールのインスタンス化
$sendmail = Email::forge();
//メール情報の設定
$sendmail->from('yamamura.capybara@gmail.com', '');
$sendmail->to($email, $username);
$sendmail->subject('パスワードの再発行');
$sendmail->html_body($body);
//メールの送信
$sendmail->send();
$view = View::forge('login/success', $data);
//該当者0のとき
} else {
$view = View::forge('login/contact', $data);
$msg = '該当者が存在しませんでした。';
$view->set('msg', $msg);
}
//バリデーションエラー
} else {
$error = $val->error();
$view = View::forge('login/contact', $data);
$view->set_global('error', $error, false);
}
//CSRF対策
} else {
$view = View::forge('login/contact', $data);
$msg = 'CSRF対策です';
$view->set('msg', $msg);
}
return $view;
}
示例10: action_recover
public function action_recover($hash = null)
{
if (Input::Method() === "POST") {
if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) {
// generate a recovery hash
$hash = \Auth::instance()->hash_password(\Str::random()) . $user->id;
// and store it in the user profile
\Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username);
// send an email out with a reset link
\Package::load('email');
$email = \Email::forge();
$html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>';
// use a view file to generate the email message
$email->html_body($html);
// give it a subject
$email->subject(\Settings::Get('site_name') . ' Password Recovery');
// GET ADMIN EMAIL FROM SETTINGS?
$admin_email = Settings::get('admin_email');
if (empty($admin_email) === false) {
$from = $admin_email;
} else {
$from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false)));
}
$email->from($from);
$email->to($user->email, $user->fullname);
// and off it goes (if all goes well)!
try {
// send the email
$email->send();
Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!');
} catch (\Exception $e) {
Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email);
\Response::redirect_back();
}
} else {
Session::Set('error', 'Sorry there is not a matching email!');
}
} elseif (empty($hash) === false) {
$hash = str_replace(Uri::Create('login/recover/'), '', Uri::current());
$user = substr($hash, 44);
if ($user = \Model\Auth_User::find_by_id($user)) {
// do we have this hash for this user, and hasn't it expired yet , must be within 24 hours
if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) {
// invalidate the hash
\Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username);
// log the user in and go to the profile to change the password
if (\Auth::instance()->force_login($user->id)) {
Session::Set('current_password', Auth::reset_password($user->username));
Response::Redirect(Uri::Create('user/settings'));
}
}
}
Session::Set('error', 'Invalid Hash!');
}
$this->template->content = View::forge('login/recover');
}
示例11: action_send_verification_email
public function action_send_verification_email($id, $mailaddress, $key)
{
$email = Email::forge();
$email->from('admin@eventual.org', 'Eventual system');
$email->to($mailaddress, "Eventual system user");
$email->subject('Your registration in Eventual');
$mail_text = "'Thank you for registering at eventual.org'\n\t\t Please, verify your address by clicking this link: " . Uri::create("account/verify/" . $id . "/" . $key . "/");
$email->body($mail_text);
$email->send();
}
示例12: sendmail
protected function sendmail($data)
{
Package::load('email');
$email = Email::forge();
$email->from($data['from'], $data['from_name']);
$email->to($data['to'], $data['to_name']);
$email->subject($data['subject']);
$email->body($data['body']);
$email->send();
}
示例13: action_index
public function action_index()
{
$this->template->title = "Remittance Payment";
$this->template->sub = "Follow the steps below to pay";
if (isset($this->user)) {
$data["student"] = Model_User::find("first", ["where" => [["deleted_at", 0], ["id", $this->user->id]]]);
}
if (Input::post('action') == 'submit') {
if (Input::post("pay-method", null) != null && Input::post("refno", null) != null) {
$checkExist = Model_Payment::find("first", ["where" => [["student_id", Input::post("studentId")], ["paid", Input::post("quarter")], ["status", 0]]]);
if ($checkExist == NULL) {
// save
$payment = Model_Payment::forge();
$payment->student_id = Input::post("studentId");
$payment->pay_method = Input::post("paymethod");
$payment->paid_at = Input::post("date");
$payment->status = 0;
$payment->method = Input::post("pay-method");
$payment->ref_no = Input::post("refno");
if (Input::post("pay-method") == 1) {
$payment->paid = "1111";
} else {
$payment->paid = Input::post("quarter");
}
$payment->save();
$data["user"] = Model_User::find("first", ["where" => [["id", Input::post("studentId")]]]);
$pay = Model_Payment::query()->where('status', 0);
$lastID = $pay->max('id');
$data["pay"] = Model_Payment::find("first", ["where" => [["id", $lastID]]]);
//sending mail
$body = View::forge("email/payment", $data);
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to("support@game-bootcamp.com");
//$sendmail->to("lasuganob123@gmail.com");
$sendmail->subject("Payment / Game-bootcamp");
$sendmail->html_body("Dear Admin,<br><br>" . htmlspecialchars_decode($body));
$sendmail->send();
Response::redirect("/students/top/?success=2");
} else {
Response::redirect("/coursefee/remit/?e=2&g=" . Input::post('paymethod', 0));
}
} else {
Response::redirect("/coursefee/?e=4");
}
}
if (isset($this->user)) {
$view = View::forge("coursefee/remit", $data);
} else {
$view = View::forge("coursefee/remit");
}
$this->template->content = $view;
}
示例14: action_index
public function action_index()
{
$id = Input::get('id', 0);
$data['payment'] = Model_Payment::find("all", ["where" => [["id", $id]]]);
//save
if (Input::post('action') == 'submit') {
if (Input::post("payid", null) != null) {
$payid = Input::post("payid", null);
$payUp = Model_Payment::find("first", ["where" => [["id", $payid]]]);
DB::update('payment')->value("status", "1")->where('id', '=', $payid)->execute();
DB::update('users')->value("charge_html", $payUp->paid)->where('id', '=', $payUp->student_id)->execute();
$data["user"] = Model_User::find("first", ["where" => [["id", $payUp->student_id]]]);
$data["pay"] = Model_Payment::find("first", ["where" => [["student_id", $payUp->student_id], ["id", $payUp->id]]]);
$user = $data["user"];
//sending mail
$body = View::forge("email/confirm", $data);
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to($user->email);
$sendmail->subject("Payment Confirmation / Game-bootcamp");
$sendmail->html_body("Dear " . $user->firstname . ",<br><br>" . htmlspecialchars_decode($body));
$sendmail->send();
Response::redirect("/admin/top/?pay=1");
} else {
}
}
if (Input::post("paymentID", 0) != 0) {
$cancel = Model_Payment::find(Input::post("paymentID", 0));
if ($cancel != null) {
//save
$cancel->reason = Input::post("explain", 0);
$cancel->status = 2;
$cancel->save();
$data["cancel"] = Model_Payment::find("first", ["where" => [["id", Input::post("paymentID", 0)]]]);
$student = $data["cancel"];
$data["student"] = Model_User::find("first", ["where" => [["id", $student->student_id]]]);
$stud = $data["student"];
//sendingmail
$body = View::forge("email/cancelpayment", $data);
$sendmail = Email::forge("JIS");
$sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
$sendmail->to($stud->email);
$sendmail->subject("Denied Payment / Game-bootcamp");
$sendmail->html_body("Dear " . $stud->firstname . ",<br><br>" . htmlspecialchars_decode($body));
$sendmail->send();
Response::redirect("/admin/top/?s=1");
}
}
$view = View::forge("admin/payment/index", $data);
$this->template->content = $view;
}
示例15: action_view
public function action_view($slug = null)
{
is_null($slug) and Response::redirect('blog/post');
$related = in_array('post', \Config::get('comment')) ? array('published_comments', 'author', 'category') : array('author', 'category');
$data['post'] = Model_Post::find('first', array('where' => array(array('slug' => $slug)), 'related' => $related));
if (!$data['post']) {
Session::set_flash('error', 'Could not find post with slug: ' . $slug);
Response::redirect('blog/post');
}
// Is the user sending a comment? If yes, process it.
if (Input::method() == 'POST') {
$val = \Comment\Model_Comment::validate('create');
if ($val->run()) {
$comment = \Comment\Model_Comment::forge(array('name' => Input::post('name'), 'email' => Input::post('email'), 'content' => Input::post('content'), 'status' => 'pending', 'post_id' => $data['post']->id));
if ($comment and $comment->save()) {
// Manually loading the Email package
\Package::load('email');
// Sending an email to the post's author
$email = \Email::forge();
$email->to($data['post']->author->email, $data['post']->author->username);
$email->subject('New comment');
$email->body(\View::forge('comment/email', array('comment' => $comment))->render());
$email->send();
unset($email);
if ($data['post']->published_comments) {
// Sending an email for all commenters
$email = \Email::forge();
$emails = array();
foreach ($data['post']->published_comments as $published_comment) {
$emails[$published_comment->email] = '\'' . $published_comment->name . '\'';
}
$email->to($emails);
$email->subject('New comment');
$email->body(\View::forge('comment/email_other', array('comment' => $comment, 'post' => $data['post']), false)->render());
$email->send();
unset($email);
}
Session::set_flash('success', e('Your comment has been saved, it will' . ' be reviewed by our administrators'));
} else {
Session::set_flash('error', e('Could not save comment.'));
}
} else {
Session::set_flash('error', $val->error());
}
}
$this->template->title = "Post";
$this->template->content = View::forge('post/view', $data);
$this->template->content->set('post_content', $data['post']->content, false);
}