On Linux how to send an email to *A* with *To: B*?
Mar 20, 11:00pm
To send an email on Linux such that the recipient A receives the email, but the To: field in the email header shows B (so A sees "To: B" when they open the email), you can use the sendmail command or a command-line email client like mail or mutt with custom headers.
Using sendmail (most common method)
You can use the following command:
bash
echo "This is the email body" | sendmail -f your_email@example.com -- A@example.com
But to set the To: header to B, you need to manually construct the email headers. Here’s how you can do it:
bash
(
echo "To: B@example.com"
echo "Subject: Your Subject Here"
echo ""
echo "This is the email body"
) | sendmail -f your_email@example.com A@example.com
Explanation:
The To: header is set to B@example.com, so A will see "To: B" in their email client.
The actual recipient is A@example.com (passed as an argument to sendmail).
Using mail or mutt
If you have mail or mutt installed, you can use:
With mail:
bash
echo "This is the email body" | mail -s "Your Subject Here" -r your_email@example.com -S "to=B@example.com" A@example.com
With mutt:
bash
echo "This is the email body" | mutt -e "set from=your_email@example.com" -s "Your Subject Here" -- A@example.com -H - <<EOF
To: B@example.com
Subject: Your Subject Here
This is the email body
EOF
Note:
Replace your_email@example.com, A@example.com, and B@example.com with the actual email addresses.
This method works because the To: header is just a header and does not control where the email is delivered. The actual recipient is specified as an argument to the command.
Mar 20, 11:00pm
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.