【问题标题】:Loading and sending email saved as text file加载和发送保存为文本文件的电子邮件
【发布时间】:2014-07-09 02:05:48
【问题描述】:

我想加载几封保存为 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 对象是唯一的解决方案吗?

【问题讨论】:

标签: php email swiftmailer


【解决方案1】:

不幸的是,您可能需要自己解析/重新填充信息。您可以尝试使用:http://www.php.net/manual/en/book.mailparse.php 和 this(围绕它的包装)https://gist.github.com/vyatri/939427 以避免手动阅读它。正确处理邮件标头可能会很棘手,因此请尽量避免手动解析并使用一些标准库来执行此操作(如前所述)。

【讨论】:

    猜你喜欢
    • 2016-04-29
    • 2011-04-12
    • 1970-01-01
    • 1970-01-01
    • 2014-11-05
    • 1970-01-01
    • 2012-08-22
    • 2014-04-04
    • 2015-07-21
    相关资源
    最近更新 更多