i want to reproduce a mail related problem regarding a mail that is sent from a system i have no control over. For this purpose i want to mimic this problematic email.
I have the exact mail as it was received as a text file (headers + base64 encoded body) How can i send a very similar mail from one of our systems?
I tried
mail -s "Test" [email protected] < mail.txt
But it puts the whole text file into the body.
thanks in advance Jens
According to RFC 5322 Internet Message Format the body of the message starts after an empty line.
You can use
awk
to print everything inmail.txt
after the first empty line, like this:So you could do something like
That, however, will start the output with an empty line. If you want to avoid that, use a slightly more complicated
awk
range:This last trick is one I picked up here.
If the machine has the
sendmail
compatibility program installed (usually it should have it, this was tested with postfix installed), then you can use a command like this:With
test.mail
looking like this for example:You will most likely not be able to reproduce too much of the original email, since many headers are only added or modified later by the mail server itself.