有效电子邮件地址上的Swift_RfcComplianceException,适用于Windows,不适用于Ubuntu [英] Swift_RfcComplianceException on valid email address, works in Windows not in Ubuntu
问题描述
我遇到了SwiftMailer似乎臭名昭著的问题:
I'm running into what appears to be a rather infamous issue with SwiftMailer:
致命错误:消息为给定[noreply@host.com]的邮箱中的地址的消息未捕获的异常 Swift_RfcComplianceException不符合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');
...
奇怪的是地址: noreply @ host .com 不会在Windows环境中运行Xampp的本地计算机上使addr-spec regex失败,但是在运行Xampp解决方案的 / opt / lampp之外的Ubuntu计算机上会失败。 code>。
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
.
- 这似乎与PCRE版本无关(两者相同),因为当我提取
添加规范
到字符串中,并通过一个简单的脚本运行该字符串以进行解析,然后将其传递。 - 没有多余的字符,没有电子邮件地址中未修饰的空格。
- 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.
更新:
查看Apache日志,我想我可能已经找到了潜在的问题:
Looking at the Apache logs I think I may have found the underlying issue:
PHP警告:preg_match():编译失败:内部错误:在/home/ubuntu/.../vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Hea中的偏移量4246处找不到先前检查的引用子模式第354行上的ders / MailboxHeader.php,引荐网址:http:// ...
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://...
因此在Windows上,正则表达式可正常编译,但在Linux上没有;
So on Windows, the regex compiles fine but on Linux it does not; unless it is extracted and the appropriate escapes put in.
在Github上发现了一些与此相关的问题:
Found a few issues on Github related to this:
- https://github.com/swiftmailer/swiftmailer/issues/279
- https://github.com/ swiftmailer / swiftmailer / issues / 259
- https://github.com/swiftmailer/swiftmailer/issues/279
- https://github.com/swiftmailer/swiftmailer/issues/259
在 @之后,似乎在抱怨子模式
标志。上面提到的Github问题中的评论之一似乎暗示着Apache处理正则表达式时会抛出该错误,这与我在Ubuntu 12.10系统(尽管不是Windows)上遇到的情况相符。
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).
这可能与Apache没有正确的PCRE支持或配置错误有关吗?
Could this have to do with Apache not having the right PCRE support or it being configured incorrectly?
谢谢!
推荐答案
我使用swiftmailer向您发送示例:
i send you on example with swiftmailer:
destinatarios:[电子邮件1,电子邮件2,电子邮件3]
destinatarios: [email1, email2, email3]
您的服务名称:
class: your path
arguments: ["%destinatarios%"]
服务等级:
受保护的$ destinatarios;
the class of the service:
protected $destinatarios;
public function __construct($destinatarios)
{
$this->destinatarios = $destinatarios;
}
->setCc($this->destinatarios)
这篇关于有效电子邮件地址上的Swift_RfcComplianceException,适用于Windows,不适用于Ubuntu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!