How can I send an email?

0

This may sound like a bit of a stupid question, but I have an RFC 2822 standard email file:

To: Mr Person <person@example.com>
Subject: Finally Figured Out How To Send Emails!
From: Josh
Date: Tue, 20 May 2013 19:05:45
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
    <head>
        <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
        <style>
            /* Some styles */
        </style>
    </head>
    <body>
        <!-- The text -->
    </body>
</html>

But how on Earth do I send it to someone? I want to send it from my GMail account, but I can't even figure out how to send it from my computer at the moment.

Zaz

Posted 2013-05-21T20:48:21.630

Reputation: 1 843

Answers

2

If your mail has got -a:

mail -a "Content-type: text/html; charset=UTF-8" -a "MIME-Version: 1.0" -a "Content-Transfer-Encoding: 7bit"-s "Finally Figured Out How To Send Emails!" person@example.com < /tmp/htmlfile.htm

Of course your mail must be configured to send emails to the outside world.

Chris

Posted 2013-05-21T20:48:21.630

Reputation: 1 766

There's no way to have mail parse the email file itself? – Zaz – 2013-05-21T20:56:51.390

well, cat emailfile.txt | telnet mail.server.com 25 – Chris – 2013-05-21T21:02:29.783

I couldn't get mail or telnet to work for me, but msmtp did the trick. Thanks for the help though! – Zaz – 2013-05-21T22:30:38.637

2

To send "the mail file" using your computer MTA:

/usr/sbin/sendmail -i -t < your-mail-file-with-headers-and-body

or if you want to set envelope sender/bounces to email address:

/usr/sbin/sendmail -fYOU@EXAMPLE.NET -i -t < your-mail-file-with-headers-and-body

-i - single dot line is not the end of message
-t - get recipients list from message headers
Sendmail "look alikes" are provided by othe MTA (Postfix/Exim/...).

You may use an mail client capable to send directly via your external email account (gmail). Take a look at "Sending Email from mailx Command in Linux Using Gmail’s SMTP" - as I understand it describes heirloom mailx.

AnFi

Posted 2013-05-21T20:48:21.630

Reputation: 771

The -t flag is quite handy, thanks! – Zaz – 2013-05-22T11:48:28.190