php Laravel 邮件中的“回复”字段不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21633509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Reply-to" field in Laravel mail is not working
提问by cawecoy
I need help to figure out how to set the reply-tofield in app/config/mail.php. I'm using Laravel 4 and it's not working. This is my app/config/mail.php:
我需要帮助来弄清楚如何reply-to在app/config/mail.php. 我正在使用 Laravel 4,但它不起作用。这是我的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,
);
回答by Colin
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:
很确定它不会以这种方式工作。您可以在配置文件中设置“From”标头,但其他所有内容都在发送过程中传递:
Mail::send('emails.welcome', $data, function($message)
{
$message->to('[email protected]', 'John Smith')
->replyTo('[email protected]', 'Reply Guy')
->subject('Welcome!');
});
FWIW, the $messagepassed to the callback is an instance of Illuminate\Mail\Message, so there are various methods you can call on it:
FWIW,$message传递给回调的是一个实例Illuminate\Mail\Message,因此您可以调用各种方法:
- ->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)
- ->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)
- -> 主题($ 主题)
- ->优先级($级别)
- ->attach($file, array $options = array())
- ->attachData($data, $name, array $options = array())
- ->嵌入($文件)
- ->embedData($data, $name, $contentType = null)
Plus, there is a magic __callmethod, so you can run any method that you would normally run on the underlying SwiftMailer class.
此外,还有一个神奇的__call方法,因此您可以运行通常在底层 SwiftMailer 类上运行的任何方法。
回答by chifliiiii
It's possible since Laravel 5.3 to add a global reply. In your config/mail.php file add the following:
从 Laravel 5.3 开始可以添加全局回复。在您的 config/mail.php 文件中添加以下内容:
'reply_to' => [
'address' => '[email protected]',
'name' => 'Reply to name',
],

