duanli9930 2013-04-12 05:30
浏览 468

有效电子邮件地址的Swift_RfcComplianceException,适用于Windows而非Ubuntu

I'm running into what appears to be a rather infamous issue with SwiftMailer:

Fatal error: Uncaught exception ‘Swift_RfcComplianceException’ with message ‘Address in mailbox given [noreply@host.com] does not comply with RFC 2822, 3.6.2.’

The message is being created with the following code (effectively):

$message = \Swift_Message::newInstance()
         ->setSubject('Subject')
         ->setFrom(array('noreply@host.com' => 'Host'))
         ->setTo('recipient@gmail.com');
...

The odd thing is that the address: noreply@host.com does not fail the addr-spec regex on a local machine running Xampp in a Windows environment, but does fail on an Ubuntu machine running the Xampp solution out of /opt/lampp.

  • This does not appear to be a problem with the PCRE version (both the same) because when I extract the add-spec to a string and run that through a simple script to parse, it passes.
  • There are no extra characters, no untrimmed white space in the email addresses.

UPDATE:

Looking at the Apache logs I think I may have found the underlying issue:

PHP Warning: preg_match(): Compilation failed: internal error: previously-checked referenced subpattern not found at offset 4246 in /home/ubuntu/.../vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php on line 354, referer: http://...

So on Windows, the regex compiles fine but on Linux it does not; unless it is extracted and the appropriate escapes put in.

Found a few issues on Github related to this:

Seems to be complaining about the subpattern after the @ sign. One of the comments in the above referenced Github issues seems to imply that the error is being thrown when Apache processes the regex, which fits with what I've experienced on an Ubuntu 12.10 system (though not on Windows).

Could this have to do with Apache not having the right PCRE support or it being configured incorrectly?

Thanks!

  • 写回答

1条回答 默认 最新

  • douwaif22244 2016-03-31 08:32
    关注

    i send you on example with swiftmailer:

    parameters.yml

    destinatarios: [email1, email2, email3]

    services:

    your service name:

        class: your path
    
        arguments: ["%destinatarios%"]
    

    the class of the service:

    protected $destinatarios;

    public function __construct($destinatarios)
    {
        $this->destinatarios = $destinatarios;
    }
    
    ->setCc($this->destinatarios)
    
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路