Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending .eml files to postfix

Posted on 2011-02-11
3
Medium Priority
?
1,756 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
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 1500 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Phishing emails are a popular malware delivery vehicle for attack.  While there are many ways for an attacker to increase the chances of success for their phishing emails, one of the most effective methods involves spoofing the message to appear to …
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

916 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