Hot to get the message ID when sending email via command line?
I am trying to send a mail via simple mail command on the command line using this piece of code:
$ echo "foo" | mail -s "Hello World" -t ""That’s working fine.
My question is the following: How can I get the MESSAGE-ID that was used for sending this mail? Is there a way to grab that information? I need this for debugging reasons.
1 Answer
The mail header MESSAGE-ID is a unique identifier. It's assigned by the mail server that sends the mail out in a specific format. Typically it's some date and time information, along with the server hostname.
Your best bet would probably be to look into how the mail server software in question builds their MESSAGE-IDs and infer the ID of your test message from that information.
As far as the command pipeline that sends the mail out is concerned (echo ... | mail ...): At that point there's no way to get the MESSAGE-ID, because it doesn't exist yet. It will only be generated later by the mail server software that mail hands the mail over to.
More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"