【问题标题】:Laravel Mail authentification troubleLaravel 邮件认证问题
【发布时间】:2015-04-02 02:44:08
【问题描述】:

大家好,我需要关于通过电子邮件发送代码的帮助 [laravel]

我收到一封电子邮件,但没有类似的链接和用户名

你好用户名

请使用以下链接激活您的帐户


链接

这是我的代码

activate.blade.php 你好 {{ '用户名' }}

请使用以下链接激活您的帐户

---
{{'链接'}}

帐户控制器

<?php

类 AccountController 扩展 BaseController {

public function getCreate() {
    return View::make('account.create');
}

    public function postCreate() {
        $validator = Validator::make(Input::all(),
            array(
                'email'          => 'required|max:50|email|unique:users',
                'username'       => 'required|max:20|min:3|unique:users',
                'password'       => 'required|min:6',
                'password_again' => 'required|same:password'

            )
        );

        if($validator->fails()) {
            return Redirect::route('account-create')
                    ->withErrors($validator)
                    ->withInput();
        } else {

            $email         = Input::get('email');
            $username  = Input::get('username');
            $password  = Input::get('password');

            //Activation code
            $code       = str_random(60);

            $user = User::create(array(
                'email' => $email,
                'username' => $username,
                'password' => Hash::make($password),
                'code' => $code,
                'active' => 0
            ));

            if($user) {

                Mail::send('emails.auth.activate', array('link' => URL::route('account-activate', $code), 'username' => $username), function($message) use ($user) {
                    $message->to($user->email, $user->username)->subject('Activate your account');
                });

                return Redirect::route('home')
                        ->with('global', 'Your account has been created! We have sent you an email to activate your account.');
            }
        }

    }

        public function getActivate($code) {

        }


}

家庭控制器

<?php

类 HomeController 扩展 BaseController { 公共函数 home() {

    Mail::send('emails.auth.activate', array('name' => 'NoReply'), function($message){
        $message->to('noreply@bla.com', 'Noreply')->subject('Noreplymail');
    });
    return View::make('home');

}

}

提前致谢。

【问题讨论】:

    标签: laravel


    【解决方案1】:

    在你的 activate.blade.php 中尝试:

    你好 {{ $username }} 
    请使用以下链接激活您的帐户
    ---
    {{ $link }}

    【讨论】:

    • 嗯?你能再解释一下你的评论吗?
    • 没错,这是一个由blade驱动的HTML模板。而且你的代码没有 HTML。
    • 已编辑。现在好看了吗?
    • 我为你编辑了它,但你应该知道 View 是一个包含 HTML 标签的 HTML 文档
    • 当我更改为 Hello {{ $username }}
      请使用以下链接激活您的帐户
      ---
      {{ $link }} 我收到错误未定义变量: 用户名(查看:/var/www/laravel/app/views/emails/auth/activate.blade.php)
    猜你喜欢
    • 2018-04-01
    • 2019-03-07
    • 2021-06-12
    • 2020-11-18
    • 2020-08-14
    • 2018-02-26
    • 2020-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多