back

Sending mail from the command line in linux

When testing things like DKIM and and spf records it’s useful to be able to send mail from the command line.

1
2
3
4
5
6
7

root@server:~# sendmail someone@gmail.com
FROM: you@yourserver.com
SUBJECT: hi
the body
.

Alternatively, it’s faster to do make a file called message.txt with something like:

1
2
3
4
5
6
7

to:someone@gmail.com
from:you@yourserver.com
subject:DKIM

This is my message.

And then

1
2
3

cat message.txt | sendmail -t

That way you can send it over and over again without having to spend any time.

August 05, 2010