I need help to figure out how to set the reply-to
field in app/config/mail.php
. I'm using Laravel 4 and it's not working. This is my app/config/mail.php
:
<?php return array( 'driver' => 'smtp', 'host' => 'smtp.gmail.com', 'port' => 587, 'from' => [ 'address' => '[email protected]', 'name' => 'E-mail 1' ], 'reply-to' => [ 'address' => '[email protected]', 'name' => 'E-mail 2' ], 'encryption' => 'tls', 'username' => '[email protected]', 'password' => 'pwd', 'pretend' => false, );
wrap it in a try catch instead, if exception not caught email is sent, otherwise it failed, try { Mail::to($userEmail)->send($welcomeMailable); } catch (Exception $e) { //Email sent failed. }
Laravel provides a clean, simple email API powered by the popular Symfony Mailer component. Laravel and Symfony Mailer provide drivers for sending email via SMTP, Mailgun, Postmark, Amazon SES, and sendmail , allowing you to quickly get started sending mail through a local or cloud based service of your choice.
Laravel provides a clean, simple API over the popular SwiftMailer library. The mail configuration file is app/config/mail. php , and contains options allowing you to change your SMTP host, port, and credentials, as well as set a global from address for all messages delivered by the library.
Pretty sure it doesn't work this way. You can set the "From" header in the config file, but everything else is passed during the send:
Mail::send('emails.welcome', $data, function($message) { $message->to('[email protected]', 'John Smith') ->replyTo('[email protected]', 'Reply Guy') ->subject('Welcome!'); });
FWIW, the $message
passed to the callback is an instance of Illuminate\Mail\Message
, so there are various methods you can call on it:
Plus, there is a magic __call
method, so you can run any method that you would normally run on the underlying SwiftMailer class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With