我想加载一些保存为txt文件的电子邮件,并使用swiftmailer发送。 Txt文件就像这样
Received: (qmail 17484 invoked from network); 1 May 2014 03:38:08 -0000
Received: from localhost (localhost [127.0.0.1])
by myserver.example.com.dyndns.org ([192.168.1.2]); 01 May 2014 03:38:08 -0000
Received: from otherserver.example.net ([127.0.0.1])
by localhost ([127.0.0.1])
with SMTP via TCP; 01 May 2014 03:38:08 -0000
Received: (qmail 4822 invoked from network); 1 May 2014 03:38:07 -0000
Received: from blablabla.example.org ([103.123.123.11])
by otherserver.example.net ([123.123.6.152])
with ESMTP via TCP; 01 May 2014 03:38:07 -0000
To: <me@example.com>
Date: Thu, 01 May 2014 12:37:29 +0900
From: <someone@example.org>
Subject: Awesome subject of email
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-2022-JP
Fantastic email text
我在Swift_Message类中找不到from_string方法。解析txt文件并使用解析信息创建一个新的Swift_Message对象是唯一的解决方案吗?
答案 0 :(得分:1)
不幸的是,您可能需要自己解析/重新填充信息。您可以尝试使用:http://www.php.net/manual/en/book.mailparse.php和this(它周围的包装)https://gist.github.com/vyatri/939427以避免必须手动读取它。邮件头可能很难做到正确,所以尽量避免手动解析并使用一些标准库来做(如上所述)。