Solved

Sending .eml files to postfix

Posted on 2011-02-11
3
1,638 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
Progress

624 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