1

I'd like to load several email saved as txt file and send them with swiftmailer. Txt files are like this

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 

I can't find a from_string method in Swift_Message class. Is parsing txt file and creating a new Swift_Message object with parsed information the only solution?

Manuel
  • 836
  • 13
  • 30
  • It's not an exact duplicate, as you are specifically asking about SwiftMailer, but have a look at this question: http://stackoverflow.com/q/5044194/1237411 – Jasper N. Brouwer May 26 '14 at 18:38
  • Not a swiftmail solution, but may solve your problem: "Given an email as raw text, how can I send it using PHP?" http://stackoverflow.com/questions/6632399/given-an-email-as-raw-text-how-can-i-send-it-using-php – bloodyKnuckles May 27 '14 at 15:09

1 Answers1

1

Unfortunately you might need to do the parsing/repopularing of the info yourself. You can try using: http://www.php.net/manual/en/book.mailparse.php and this (a wrapper around it) https://gist.github.com/vyatri/939427 to avoid having to read it manually. Mail headers can be tricky to get right so try to avoid manual parsing as much as possible and use some standard library to do it (like the mentioned).

Feras
  • 2,114
  • 3
  • 20
  • 42