La posta di default di Laravel non funziona

Sto tentando di submit un'e-mail di triggerszione utente al momento della logging. Ho un semplice sito laravel con logging e authentication. Al momento della logging, non ci sono errori e i dati vengono archiviati correttamente, tuttavia l'e-mail non viene mai inviata. Ho provato alcuni esempi diversi, ma ho lo stesso problema.

Questo è il mio file di configuration mail.php

<?php return arrays( /* |-------------------------------------------------------------------------- | Mail Driver |-------------------------------------------------------------------------- | | Laravel supports both SMTP and PHP's "mail" function as drivers for the | sending of e-mail. You may specify which one you're using throughout | your application here. By default, Laravel is setup for SMTP mail. | | Supported: "smtp", "mail", "sendmail" | */ 'driver' => 'smtp', /* |-------------------------------------------------------------------------- | SMTP Host Address |-------------------------------------------------------------------------- | | Here you may provide the host address of the SMTP server used by your | applications. A default option is provided that is compatible with | the Postmark mail service, which will provide reliable delivery. | */ 'host' => 'smtp.mailgun.org', /* |-------------------------------------------------------------------------- | SMTP Host Port |-------------------------------------------------------------------------- | | This is the SMTP port used by your application to delivery e-mails to | users of your application. Like the host we have set this value to | stay compatible with the Postmark e-mail application by default. | */ 'port' => 587, /* |-------------------------------------------------------------------------- | 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' => arrays('address' => '[email protected]', 'name' => 'God'), /* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol |-------------------------------------------------------------------------- | | Here you may specify the encryption protocol that should be used when | the application send e-mail messages. A sensible default using the | transport layer security protocol should provide great security. | */ 'encryption' => 'tls', /* |-------------------------------------------------------------------------- | SMTP Server Username |-------------------------------------------------------------------------- | | If your SMTP server requires a username for authentication, you should | set it here. This will get used to authenticate with your server on | connection. You may also set the "password" value below this one. | */ 'username' => null, /* |-------------------------------------------------------------------------- | SMTP Server Password |-------------------------------------------------------------------------- | | Here you may set the password required by your SMTP server to send out | messages from your application. This will be given to the server on | connection so that the application will be able to send messages. | */ 'password' => null, /* |-------------------------------------------------------------------------- | Sendmail System Path |-------------------------------------------------------------------------- | | When using the "sendmail" driver to send e-mails, we will need to know | the path to where Sendmail lives on this server. A default path has | been provided here, which will work well on most of your systems. | */ 'sendmail' => '/usr/sbin/sendmail -bs', /* |-------------------------------------------------------------------------- | Mail "Pnetworkingnd" |-------------------------------------------------------------------------- | | When this option is enabled, e-mail will not actually be sent over the | web and will instead be written to your application's logs files so | you may inspect the message. This is great for local development. | */ 'pnetworkingnd' => false, ); 

E questa è la logica per gestire il mailer – (Questo è in UsersController)

 public function postCreate() { $validator = Validator::make(Input::all(), User::$rules); if ($validator->passes()) { $act_code = str_random(60); $user = new User; $user->user_username = Input::get('user_username'); $user->user_email = Input::get('user_email'); $user->user_password = Hash::make(Input::get('user_password')); $user->user_status = "N"; $user->user_activation_key = $act_code; if($user->save()) { $email_data = arrays( 'recipient' => $user->user_email, 'subject' => 'Activation Email' ); $view_data = arrays( 'actkey' => $act_code, ); Mail::send('emails.welcome', $view_data, function($message) use ($email_data) { $message->to( $email_data['recipient'] ) ->subject( $email_data['subject'] ); }); return Redirect::to('login')->with('message', 'Thanks for registering!'); } } else { return Redirect::to('register')->with('message', 'The following errors occurred')->withErrors($validator)->withInput(); } } 

Ok, darei a Yousef un "Up One", ma la mia reputazione non è abbastanza alta (sembra rotta). Ho avuto ESATTAMENTE lo stesso problema con il mio ISP in connessione al proprio server smtp. L'unico modo per get FINALMENTE una e-mail usando laravel è stato di impostare il valore 'encryption' su zero (cioè come nel post precedente). Ogni altra combinazione di cambio di port, cambio di account, ecc. Ha provocato un'exception di laravel. Ho provato a utilizzare il mio account e le credenziali di Gmail senza fortuna.

L'unica combinazione di impostazioni che alla fine ha funzionato è stata l'utilizzo

 'host' => 'smtp.your-domain', 'port' => 587, 'encryption' => '', 'username' => '[email protected]', 'password' => 'your-password for Your-account',... 

Espandere le risposte sopra perché non stavano funzionando per me.

La port che hai definito deve essere correlata al giusto tipo di crittografia. Come risulta, ssl e tls non sono equivalenti e sono correlati a porte differenti.
L'impostazione di crittografia predefinita in laravel è impostata su tls (port 587), ma se si utilizza la port 465, è necessario cambiarla in ssl.

Il server smtp.gmail.com di Google è un buon esempio di questo:

 'host' => 'smtp.gmail.com', 'port' => 465, 'encryption' => 'ssl', 

O

 'host' => 'smtp.gmail.com', 'port' => 587, 'encryption' => 'tls', 

Inoltre, la port 587 non impone l'uso della crittografia (di più su questo qui ). Se ritieni che l'impostazione 'encryption' => '' funzioni per te, dovrebbe generare una bandiera rossa poiché potrebbe significare che il server smtp che stai utilizzando non sta crittografando le tue email.
In questo caso, dovresti trovare mezzi alternativi per submit le tue email.

prova a rimuovere la crittografia tls impostandola su

 'encryption' => '', 

ho avuto un problema simile, e il tls è stato.

Se lo stai usando su una macchina locale usando Xampp. Si prega di disabilitare tutte le applicazioni di crittografia in esecuzione nel back-end. Avevo riscontrato lo stesso problema ed è stato risolto quando ho distriggersto il software di crittografia PGP. Il software di crittografia non consente di passare token alla posta elettronica.

Config / mail.php

 <?php return [ /* |-------------------------------------------------------------------------- | Mail Driver |-------------------------------------------------------------------------- | | Laravel supports both SMTP and PHP's "mail" function as drivers for the | sending of e-mail. You may specify which one you're using throughout | your application here. By default, Laravel is setup for SMTP mail. | | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log" | */ 'driver' => 'sendmail', /* |-------------------------------------------------------------------------- | SMTP Host Address |-------------------------------------------------------------------------- | | Here you may provide the host address of the SMTP server used by your | applications. A default option is provided that is compatible with | the Mailgun mail service which will provide reliable deliveries. | */ 'host' => 'smtp.gmail.com', /* |-------------------------------------------------------------------------- | SMTP Host Port |-------------------------------------------------------------------------- | | This is the SMTP port used by your application to deliver e-mails to | users of the application. Like the host we have set this value to | stay compatible with the Mailgun e-mail application by default. | */ 'port' => 465, /* |-------------------------------------------------------------------------- | 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' => 'your mail', 'name' => 'Project'], /* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol |-------------------------------------------------------------------------- | | Here you may specify the encryption protocol that should be used when | the application send e-mail messages. A sensible default using the | transport layer security protocol should provide great security. | */ 'encryption' => '', /* |-------------------------------------------------------------------------- | SMTP Server Username |-------------------------------------------------------------------------- | | If your SMTP server requires a username for authentication, you should | set it here. This will get used to authenticate with your server on | connection. You may also set the "password" value below this one. | */ 'username' => 'your email (gmail)', /* |-------------------------------------------------------------------------- | SMTP Server Password |-------------------------------------------------------------------------- | | Here you may set the password required by your SMTP server to send out | messages from your application. This will be given to the server on | connection so that the application will be able to send messages. | */ 'password' => 'password (email)', /* |-------------------------------------------------------------------------- | Sendmail System Path |-------------------------------------------------------------------------- | | When using the "sendmail" driver to send e-mails, we will need to know | the path to where Sendmail lives on this server. A default path has | been provided here, which will work well on most of your systems. | */ 'sendmail' => '/usr/sbin/sendmail -bs', /* |-------------------------------------------------------------------------- | Mail "Pnetworkingnd" |-------------------------------------------------------------------------- | | When this option is enabled, e-mail will not actually be sent over the | web and will instead be written to your application's logs files so | you may inspect the message. This is great for local development. | */ 'pnetworkingnd' => false, ]; 

La function mail

 use Illuminate\Contracts\Mail\Mailer; $message = [ 'title' => 'Verification code', 'intro' => "Please verify your email address with ".$user->confirmation_code, 'link' => '', 'confirmation_code' => '', 'to_email' => $user->email, 'to_name' => $user_details->first_name.' '.$user_details->last_name, ]; \Mail::send('emails.auth.verify', $message, function($m) use($message) { $m->to($message['to_email'], $message['to_name']) ->subject('Email verification'); });