I have a folder full of formatted email files, one email per file. These are complete with headers for from/to/subject etc, something like:
I would like to be able to “send” them out via a mail server, but I can’t figure out how to do that. Most of the AppleScript stuff I have found refers to setting the from/to headers, etc, but all that is already done.
I have access to MacOS X Server if that makes a difference - I can’t figure out a way to do this directly with the Postfix mail server though.
set emailFile to read alias "path:to:mail_file.txt"
set {toField, fromField} to parse(emailFile)
send raw mail to toField from fromField raw source emailFile SMTP server "smtp.server.com" authentication auto username "username" password "password"
to parse(txt)
set sample to paragraphs 1 thru 5 of txt
repeat with i from 1 to count sample
if sample's item i starts with "to:" then set t to text 5 thru -1 of sample's item i
if sample's item i starts with "from:" then set f to text 7 thru -1 of sample's item i
end repeat
{t, f}
end parse
As you see, you can adaptate the “parse” handler easilly to grab whatever info from your headers. Anyway, with the “send raw mail” command (instead of the more simple “send mail”), you will need only extract the “to” and “from” fields…