2016-10-16 3 views
0

私はもう一度試してみましたが、登録時に新しいユーザーにウェルカム/検証トークンメッセージを送信することに固執しています。私は5.2と5.3でログファイルに書き込むことができました。確認の電子メールトークンはうまく動作しますが、実際のメールをユーザ(自分自身)に送ることはできません。メールガンメールとLaravel

誰かがこのコードを見て、どこに間違っているのか教えてください。私のドメインはMailgunで検証されます。私が混乱していることの1つは、作成した郵便受けドメインからサブドメインを作成する方法です。私は '[email protected]'のようなものを使用したいが、私がMailgunに登録したものはすべて 'mg.mydomain.com'である。私が得ている多くのエラーの1つは "指定メールボックスのアドレス[RFC 2222] 、3.6.2。 LaravelまたはMailgunは 'から' のアドレスを認識していないように私は設定の\ mail.phpで作成した

.env:

MAIL_DRIVER=mailgun 
MAIL_HOST=smtp.mailgun.org 
MAIL_PORT=587 
[email protected][mydomain].com // note, this is not configured on Mailgun I am trying to create subdomain here 
MAIL_PASSWORD=[ "Default Password" on Mailgun dashboard -> encrpyted] 
MAIL_ENCRYPTION=null 
MAILGUN_D[email protected][mydomain].com // provided via Mailgun dashboard 
MAILGUN_SECRET=key-[...API Key] 

.RegistersUsersトレイト:

use App\Mail\NewUserRegMail; 
use Illuminate\Support\Facades\Mail; 
use Illuminate\Http\Request; 
use Illuminate\Support\Facades\Auth; 
use Illuminate\Auth\Events\Registered; 

public function register(Request $request) 
{ 

    $this->validator($request->all())->validate(); 

    event(new Registered($user = $this->create($request->all()))); 

    // $this->guard()->login($user); 

// Send email and token to the NewUserRegMail class, this works 
    Mail::to($request->user())->send(new NewUserRegMail($request->email, $request->_token)); 

    // redirect to login 
    return redirect($this->redirectPath()); 
} 

//カスタムメールApp \ mail.php .NewUserRegMail内のクラス:

<?php 

namespace App\Mail; 

use App\User; 
use Illuminate\Bus\Queueable; 
use Illuminate\Mail\Mailable; 
use Illuminate\Queue\SerializesModels; 
use Illuminate\Contracts\Queue\ShouldQueue; 

class NewUserRegMail extends Mailable 
{ 
    use Queueable, SerializesModels; 

    protected $_token; 
    protected $email; 
    protected $token; 
    // pass in User to construct 

    /** 
    * Create a new message instance. 
    * 
    * @return void 
    */ 
    public function __construct($email, $_token) 
    { 
     $this->email = $email; 
     $this->_token = $_token; 
    } 

    /** 
    * Build the message. 
    * 
    * @return $this 
    */ 
    public function build() 
    { 
     return $this->from('[email protected]') 
         ->subject('Register your email') 
        ->view('auth.emails.confirm') 
        ->with([ 
         'to' => $this->email, 
         'token' => $this->_token 
        ]); 
    } 
} 

の.config \ mail.php

'driver' => env('MAIL_DRIVER', 'mailgun'), 
    'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 
    'port' => env('MAIL_PORT', 587), 
    'from' => [ 
    'address' => '[email protected]', 
    'name' => null 
], 
    'encryption' => env('MAIL_ENCRYPTION', 'tls'), 
    'username' => env('MAIL_USERNAME'), 
    'password' => env('MAIL_PASSWORD'), 
    'sendmail' => '/usr/sbin/sendmail -bs', 

長い記事について謝罪が、私は私が間違って

感謝を行くよどこがわからないよう可能な限り明確にしたかったです!

答えて

0

解決済み! 私は別の変数に電子メールを抽出しなければならなかった

$ email = $ request-> email; Mail :: to($ email ....);

今すぐダウンロード!