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
Solved

Sending .eml files to postfix

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
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…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

861 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