Solved

Sending .eml files to postfix

Posted on 2011-02-11
3
1,586 Views
Last Modified: 2013-12-18
I have a postfix mail server setup that is currently sending/receiving mail just fine.  We want to set up a folder on the postfix box for an application to write/transfer .eml files to to get mailed out.  Is there a way to tell postfix to grab the files from that folder or a way to take the files from that folder and forward them to postfix so that they get mailed?
0
Comment
Question by:swagers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:nxnw
ID: 34876069
You may be able to do it with the mail command in a shell script invoked periodically by launchd.

See man mail in terminal.
0
 

Author Comment

by:swagers
ID: 34883726
Looked through the mail manual didn't see a way to send the .eml file as the actual message.  Also I should mention that the postfix server is running two instances of postfix, as its sending and signing mail for two seperate domains, so it would also be helpful to be able to specify which instance of postfix that the .eml file is being sent to.
0
 
LVL 27

Accepted Solution

by:
skullnobrains earned 500 total points
ID: 35497409
eml files do not preserve envelope information

you may write a simple shell script to parse the headers and send the mail to postfix using a simple netcat if you believe you can trust the to and from headers

this is a sample you should be able to adapt to your needs

file=$1
rcpt=`sed -n 's/To:.*<\([^<>]*\)>.*/\1/p'`
test -n $rcpt || rcpt=`sed -n 's/To:[[:space:]]*\([^[:space:]]*\)[[:space:]]*/\1/p'`

{
echo 'helo local_eml_sender'
echo 'mail from: <>'
echo 'rcpt to: <$rcpt>'
echo data
cat $file | sed 's/^./../'
echo -e "\r\n.\r\n"
sleep 5
} | nc localhost 25 | grep queued\ as \
&& rm $file

you can work without  the sleep hack if you use freebsd which has a proper nc implementation

you can build a much better email sender with netpipes but you probably would use a more convenient programing language then

good luck

ps script would be launched using find and xargs so you spawn it once per file.
something like this :
find $eml_directory -type f -name \*.eml | xargs -n1 -p 10 path/to/script
would run 10 parallel instances of the script
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question