I want to send e-mails from my Raspberry Pi. I saw many methods but they are using an existing e-mail account (Gmail for example), I don't want to do this. I want to send my mail just knowing the receiver e-mail address. Gmail can do this so I believe I can, I just couldn't find any proper explanation of what I need.



You either need to have an own domain (www.somedomain.net) with an smtp server or you need to use freemailers like gmail, yahoo, etc. to send mails via smtp.

If this wouldn't be the case, we'd have to deal with much more SPAM mails.

A simple tool to send mail is swaks (install with apt-get install swaks)

Swiss Army Knife SMTP, the all-purpose smtp transaction tester

Here is an (untested) example that might work with gmail (unless you've enabled two factor authentication), or with any other smtp server.

 echo "Hello world" | swaks -4 --server smtp.gmail.com:587 --from user@gmail.com \
--to user@example.net -tls --tls-protocol sslv3 --auth PLAIN --auth-user user@gmail.com \
--auth-password my_secret_password --h-Subject "Test message" --body -
  • 1
    Historical remark: In the mid-90ies I've accidently become sysadmin. Back then it was still common that everybody could send e-mails from their command lines without creating any user accounts. Our HP-UX boxes were configured with sendmail to relay anything until someone found them to serve as spam relays and our machines got blacklisted. I tried to port sendmail 8 (first version with authentication) to HP-UX (which didn't succeed) and finally switched to qmail. – Philippos Mar 13 '17 at 13:03
  • 2
    (continued...) It was hard work to get our mail server from the blacklists. Since those days you can theoretical still send e-mails directly from your machine, but you won't find many recipient servers that will accept those e-mails. – Philippos Mar 13 '17 at 13:04
  • Can I run smtp server on Raspberry Pi (without any static ip or something) and use something like swaks --server localhost:587 ? – Enis Turgut Yalçınkaya Mar 14 '17 at 10:36
  • 2
    You surly can install a MTA like postfix and send mails with the mail command. But the emails would be rejected. – Michael D. Mar 14 '17 at 11:01
  • 1
    This answer is a bit subjective and misses a lot of the nuance. You most definitely can still send email from any machine and yes this is likely to be blocked as spam by the major email providers but the way to avoid this isn't as simple as "having your own domain". The first common layers of protection often include 1) having your server's IP registered with a reverse DNS to your own domain. 2) not using a domestic IP (home ISP). – Philip Couling Jun 9 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.