0

In exim4, I use following pipe to send a message to a python script, process it, and upload it to django:

send_to_django_mailbox:
  driver = pipe
  command = /usr/local/bin/python /etc/exim4/conf.d/transport/send_mail.py $message_body  $message_headers_raw
  return_path_add
  delivery_date_add

instead of passing in $message_body and $message_headers_raw I would like to pass in the very raw message, without any substitution. How can I achieve it? I cannot find a variable message_raw or similar.

2 Answers 2

1

Exim can pipe message to another process, and from that process message is accessible via /dev/stdin file. For example, from shell we can read message line by line like that:

#!/bin/sh

while read line
do 
  echo (( $line ))
done < /dev/stdin
#####
0

Ok, stupid me, I should had read the documentation more carefully:

The plain message is send to the script via stdin, I don't have to pass it in via command line parameters.

in python it would be like

import sys

for line in sys.stdin:
    the_file.write(line)
2
  • Even more - you can open /dev/stdin for reading and your message is here. That is very useful with shell scripts where there is no sys module.
    – Kondybas
    Jan 4, 2014 at 14:51
  • @Kondybas: make it an answer and I'll accept it. Jan 4, 2014 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .