"回复到QUOT&; Laravel邮箱中的字段不工作 [英] "Reply-to" field in Laravel mail is not working

查看:156
本文介绍了"回复到QUOT&; Laravel邮箱中的字段不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助,找出如何在 app / config / mail.php 回复字段>。我正在使用Laravel 4,它不工作。这是我的 app / config / mail.php

  ?php 

return array(
'driver'=>'smtp',
'host'=>'smtp.gmail.com',
'端口'=> 587,
'from'=> [
'address'=>'sender@domain.com',
'name'=>'电子邮件1'
],
'reply-to'=> [
'address'=>'replyto@domain.com',
'name'=>'电子邮件2'
],
'encryption'=>'tls',
'username'=>'sender@domain.com',
'password' =>'pwd',
'pretend'=> false,
);


解决方案

很确定它不会这样工作。您可以在配置文件中设置发件人标题,但在发送过程中会传递其他所有内容:

  Mail :: send ('emails.welcome',$ data,function($ message)
{
$ message-> to('foo@example.com','John Smith')
- > ; replyTo(isply@example.com','Reply Guy')
- > subject('Welcome!');
});

FWIW, $ message 传递给回调是 Illuminate\Mail\Message 的一个实例,所以有各种方法可以调用它:



< ($ address,$ name = null)
  • - >发件人($ address,$ name = null)

  • - > returnPath($ address)

  • - >($ address,$ name = null)

  • - > cc $地址,$ name = null)

  • - > bcc($ address,$ name = null)

  • - > replyTo($ address,$ $($ subject)

  • - >主题($ subject)

  • - >优先级($ level)

  • $($ data,$ name,array $ options = array())

  • - > embed($ file)

  • - > embedData($ data,$ name,$ contentType = null)



  • 另外,还有一个魔术 __调用方法,因此您可以运行任何通常在底层SwiftMailer类上运行的方法。


    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,
    );
    

    解决方案

    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 Illuminate\Mail\Message, 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.

    这篇关于&QUOT;回复到QUOT&; Laravel邮箱中的字段不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆