Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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' => 'sender@domain.com',
        'name' => 'E-mail 1'
    ],
    'reply-to' => [
        'address' => 'replyto@domain.com',
        'name' => 'E-mail 2'
    ],
    'encryption' => 'tls',
    'username' => 'sender@domain.com',
    'password' => 'pwd',
    'pretend' => false,
);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
727 views
Welcome To Ask or Share your Answers For Others

1 Answer

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('foo@example.com', 'John Smith')
        ->replyTo('reply@example.com', 'Reply Guy')
        ->subject('Welcome!');
});

FWIW, the $message passed to the callback is an instance of IlluminateMailMessage, so there are various methods you can call on it:

  • ->from($address, $name = null)
  • ->sender($address, $name = null)
  • ->returnPath($address)
  • ->to($address, $name = null)
  • ->cc($address, $name = null)
  • ->bcc($address, $name = null)
  • ->replyTo($address, $name = null)
  • ->subject($subject)
  • ->priority($level)
  • ->attach($file, array $options = array())
  • ->attachData($data, $name, array $options = array())
  • ->embed($file)
  • ->embedData($data, $name, $contentType = null)

Plus, there is a magic __call method, so you can run any method that you would normally run on the underlying SwiftMailer class.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...