doulou1989 2016-11-10 16:48
浏览 79


I need send an email invitation from My app to new users. I have no any idea about how to manage controller? this is My blade view


<!-- Main Content -->
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Send E-Mail Invitation</div>
                <div class="panel-body">
                    @if (session('status'))
                        <div class="alert alert-success">
                            {{ session('status') }}

                    <form class="form-horizontal" role="form" method="POST" action="{{ url('/password/email') }}">
                        {{ csrf_field() }}

                        <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                            <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}">

                                @if ($errors->has('email'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('email') }}</strong>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-4">
                                <button type="submit" class="btn btn-primary">
                                    <i class="fa fa-btn fa-envelope"></i> Send Invitation Link

I need simply enter an email address and send invitation mail. I have configure gmail as My email client. can you help me?

  • 写回答

1条回答 默认 最新

  • doukang7501 2016-11-10 18:08

    You can send Mails using Laravel Mail Class like this,

    Your controller should look like this:

    use Mail;
    class EmailsController {
    public function send(Request $request)
        $email = $request->get('email');
        Mail::send('emails.send', ['email' => $email], function ($message) use ($email)
            $message->from('', 'Your Name');
        return response()->json(['message' => 'Invitation Email Sent!']);

    Your view should be in directory - resources/views/emails/send.php

      <body style="background: black; color: white">
        <h1>Email Invitation</h1>
        <p>Hello - {{$email}}</p>

    Note: Remember to configure your .env file for mails:


    Don't forget to run php artisan config:cache after you make changes in your .env file. Hope this helps!

    Also remember to configure your mail.php file ioside config/mail.php like this:

    | Global "From" Address
    | You may wish for all e-mails sent by your application to be sent from
    | the same address. Here, you may specify a name and address that is
    | used globally for all e-mails that are sent by your application.
    'from' => ['address' => '', 'name' => 'Your name'],

    Configure this file above, if you want more help then - see this

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥15 这个四人抢答器代码哪儿有问题?仿真程序怎么写?
    • ¥15 burpsuite密码爆破
    • ¥15 关于#ubuntu#的问题,如何解决?(相关搜索:移动硬盘)
    • ¥15 scikit安装之后import不了
    • ¥15 Ros2编译一个使用opencv的c++节点的时候,报了这个错误,请问怎么解决啊
    • ¥15 人脸识别相关算法 YOLO,AI等
    • ¥15 spark问题方便加V17675797079
    • ¥15 Python代码不打印的原因
    • ¥20 微软SEAL库的安装和使用,VS2022环境配置问题
    • ¥15 数学问题也不知道那种类型的问题