问题描述
我遇到了SwiftMailer似乎臭名昭著的问题:
I'm running into what appears to be a rather infamous issue with SwiftMailer:
正在使用以下代码创建消息(有效):
The message is being created with the following code (effectively):
$message = \Swift_Message::newInstance()
->setSubject('Subject')
->setFrom(array('[email protected]' => 'Host'))
->setTo('[email protected]');
...
奇怪的是地址: noreply @ host .com 不会在Windows环境中运行Xampp的本地计算机上使addr-spec regex失败,但是在运行Xampp解决方案的 / opt / lampp之外的Ubuntu计算机上会失败。 code>。
The odd thing is that the address: [email protected] 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:
因此在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
在 @之后,似乎在抱怨子模式
标志。上面提到的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!