Laravel Standard-E-mail funktioniert nicht
Im Versuch zum senden einer user-Aktivierungs-E-Mail nach der Anmeldung. Ich habe eine einfache laravel Website mit Registrierung und Authentifizierung. Bei der Registrierung, es gibt keine Fehler und die Daten werden korrekt gespeichert, aber die E-Mail nie wirklich geschickt bekommt. Habe versucht ein paar verschiedene Beispiele, aber ich habe das gleiche problem.
Dies ist mein mail.php config-Datei -
<?php
return array(
/*
|--------------------------------------------------------------------------
| 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' => array('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 "Pretend"
|--------------------------------------------------------------------------
|
| 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.
|
*/
'pretend' => false,
);
- Und dies ist die Logik für die Behandlung der mailer - (Dies ist im 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 = array(
'recipient' => $user->user_email,
'subject' => 'Activation Email'
);
$view_data = array(
'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();
}
}
Du musst angemeldet sein, um einen Kommentar abzugeben.
Okay, ich gebe Yousef eine "nächsthöhere"
aber mein Ruf ist nicht hoch genug ist (scheint defekt). Ich hatte GENAU das gleiche Problem mit meinem ISP in Verbindung, um Ihre smtp-server. Nur so konnte ich ENDLICH eine E-Mail durch die Verwendung von laravel war, die 'Verschlüsselung' Wert nichts (also so wie im post oben). Jede andere Kombination von port-änderung Konto-änderung, etc. führte zu einer laravel Ausnahme. Ich habe versucht mit meinem gmail-Konto und Anmeldeinformationen nicht mit Glück.
Nur die Kombination von Einstellungen, die schließlich funktionierte, war der Einsatz von
Ausbau auf die oben genannten Antworten, wie Sie waren nicht für mich arbeiten.
Den port ein, den Sie definieren, ist zu korrelieren mit der richtigen Art von Verschlüsselung. Wie es sich herausstellt, ssl und tls sind nicht äquivalent und beziehen sich auf verschiedene Anschlüsse.
Die Standard-Verschlüsselungseinstellung in laravel ist auf tls (port 587), aber wenn Sie über port 465, müssen Sie es ändern, um die ssl.
Google smtp.gmail.com server ist ein gutes Beispiel dafür:
ODER
Darüber hinaus ist der port 587 nicht vorschreiben die Verwendung von Verschlüsselung (mehr dazu hier). Wenn Sie feststellen, dass die Einstellung
'encryption' => ''
für Sie arbeitet, sollte es eine rote fahne, wie es kann bedeuten, dass der smtp-server, den Sie verwenden, ist nicht die Verschlüsselung Ihrer E-Mails.In diesem Fall sollten Sie alternative Mittel zum versenden Ihrer E-Mails.
versuchen Sie tls-Verschlüsselung mit der Einstellung
ich hatte ein ähnliches Problem, und der tls war es.
Wenn Sie diese auf dem lokalen Rechner mit Xampp. Bitte deaktivieren Sie die Verschlüsselung Anwendung, die läuft auf dem back-end. Ich hatte erfahrenen das gleiche Problem und es wurde gelöst, wenn ich deaktiviert PGP-Verschlüsselung-software. Die Verschlüsselungs-software nicht erlauben, um pass-token in der E-Mail.
Hatte ich dieses problem, aber ich stellen Sie die Konfiguration mail .env-Datei und ich habe diese: