Sending mail from the command line

15

2

Ok, I've looked far and wide for something to take care of this little email project I have.

First, some background: My family has a secret santa every year and I've offered to write a script to randomize who gets gifts for whom. What I'd like to do is send an email letting people know who they'll be getting a gift for but I DON'T want to send the email through my gmail account since I'll be involved in the Secret Santa.

The question: how can I send an email from the command line/a script without having that email stored in my "sent items" in my gmail account (or any other mail account). I think i'd have set up my own smtp server, but I'm really pretty clueless.

Ramy

Posted 2012-09-21T19:03:13.807

Reputation: 1 005

1That's a great idea! – SaintWacko – 2012-09-21T19:44:58.810

You will want to keep in mind that if you're not using a SMTP server then there is a chance that you will be sending the email to their Junk/Spam mail. If you are using an SMTP server (local on network) then make sure that your ISP will allow you to host servers behind your internet connection. Many will shut you down (in the US) almost immediately. – kobaltz – 2012-09-21T20:04:09.163

Just make sure everyone knows it's sent from a script. I did this last year, and half of the people immediately sent me a message complaining/rejoicing about who they got. – Dean – 2012-09-21T21:46:21.370

Answers

8

You do need a special SMTP server, but you don't need to set it up yourself. As somebody has already suggested, you can create a bogus Gmail account and use the SMTP for that. Or, for really anonymity, you can use a SMTP provider; this will allow you to forge your return address (the same way spammers do) for an extra layer of anonymity and customization ("From: YourFriend@SecretSanta.com").

Here's help on configuring sendmail to use SMTP, useful when specifying headers directly instead of relying on your mail client.

Isaac Rabinovitch

Posted 2012-09-21T19:03:13.807

Reputation: 2 645

3Hm, my example of a forged From: header made wonder if there really is a SecretSanta.com. And indeed there is: they provide a turnkey solution to this very problem. – Isaac Rabinovitch – 2012-09-21T19:39:33.640

hahaha, brilliant! – Ramy – 2012-09-21T19:56:40.933

1@Ramy I just realized that somebody who knows how can look at the headers of an email and figure out the IP address of the machine running the script. Might be able to deduce your identity from that. Obviously not an issue if all recipients are technically challenged. – Isaac Rabinovitch – 2012-09-21T20:16:39.387

oh, yeah, thanks for the insight but i'm sending an email telling everyone who their secret santa is. So...knowing where the email is irrelevant. So long as the sender of the email (me!) can't see what's in it to figure out who's getting them (me!) a gift. make sense? – Ramy – 2012-09-22T01:58:48.203

1

Since "sent mail" is just a tag in Gmail (only a single copy of each mail exists with different tags) and you apparently cannot turn it off (as with Yahoo Mail, for example), you'd either need to delete the message if you want no record of it, or hide the "sent mail" folder.

Why not create a new Gmail account, then use it for sending but never check it? As for the actual command-line sending part, I'm sure it has already been answered here (see Ubuntu command line email tool for server for example).

Karan

Posted 2012-09-21T19:03:13.807

Reputation: 51 857

well, yes that's a possibility, but I'd really like it if I could just have no record. If I create a new gmail account, I still have access to it. It's definitely a route I can take but it seems like I should be able to just send some text to an email address without recording what was sent. – Ramy – 2012-09-21T19:30:56.817