Page 1 of 1

HOWTO send email with your Raspberry Pi

Posted: Thu Mar 10, 2016 10:32 am
by Randall
Been struggling to get this to work, but the solution is simple.

Step 1- Install sendemail

Code: Select all

sudo apt-get install sendemail
Step 2- When finished, confirm it is installed properly

Code: Select all

$sendEmail
It will give you a whole screen full of options

Step 3- Sending an email

Code: Select all

sendEmail -f myaddress@isp.net \
-t myfriend@isp.net \
-s relay.isp.net \
-u "Test email" \
-m "Hi , this is a test email."
-f = sender's email address (can be spoofed)
-t = destination email address (MUST be valid)
-s = outgoing relay, look this up, for Cell C this is mail.cmobile.co.za
-u = Subject line (all text MUST be in quotes i.e. "")
-m = message body (all text MUST be in quotes i.e. "")

As simple as that.

Re: HOWTO send email with your Raspberry Pi

Posted: Thu Mar 10, 2016 10:52 am
by Raven Song
I'd like you to know... you speak a whole new language to me and it's freaking cool...

If I had the patience I'd try to learn this...

Re: HOWTO send email with your Raspberry Pi

Posted: Thu Mar 10, 2016 10:57 am
by Randall
There's nothing special here, this is all text entered in the Linux shell.
This can be made to work on any Linux system, and probably on OS X aswell.

The reason this is nifty is because you do not need to install an MTA such as sendmail/exim, which are usually difficult to configure. It just works without you having to fiddle with any MTA

Re: HOWTO send email with your Raspberry Pi

Posted: Thu Mar 10, 2016 11:01 am
by Leeward
That's why I love Python. Everything works straight out of the box.

Re: HOWTO send email with your Raspberry Pi

Posted: Thu Mar 10, 2016 11:19 am
by Randall
So since this works, I am just going to write a wrapper in C and feed it all the bits from the arguments passed....

Re: HOWTO send email with your Raspberry Pi

Posted: Thu Mar 10, 2016 11:30 am
by Raven Song
And more weird language and words...

You guys really do speak a whole new world sometimes :P

I have never met any rappers who did anything in C, be it major or minor :P (worst. music. joke. ever....)

Re: HOWTO send email with your Raspberry Pi

Posted: Thu Mar 10, 2016 10:47 pm
by Rakuen Growlithe
Does that mean you can send email without an email account?

Re: HOWTO send email with your Raspberry Pi

Posted: Fri Mar 11, 2016 8:05 am
by Randall
Rakuen Growlithe wrote:Does that mean you can send email without an email account?
Correct, that is what I did. That is what was required of the project.

I also suspect this is how my NAS drive at home is doing it.

Re: HOWTO send email with your Raspberry Pi

Posted: Fri Mar 11, 2016 8:16 am
by Valerion
You need to specify a "from" address, but it doesn't strictly need to be valid. Email is the easiest thing in the world to spoof. However, anti-spam measures may catch the invalid ones.

I have recently started to implement SPF, DKIM and DMARC specifically to combat this. Which is when found out that Google gets spam from my personal domain from India.

Re: HOWTO send email with your Raspberry Pi

Posted: Sat Mar 12, 2016 1:20 pm
by Randall
Quite correct Valerion. Quite correct.

This is for internal use, so I don't stress, just happy it works.

Its actually part of a system that is going to help automate JUnit testing.

Re: HOWTO send email with your Raspberry Pi

Posted: Sat Mar 12, 2016 3:13 pm
by Rakuen Growlithe
Out of curiosity, what makes an email address valid? Can you just give yourself one or does it need to be tied to a domain name?

Re: HOWTO send email with your Raspberry Pi

Posted: Sat Mar 12, 2016 7:19 pm
by Randall
Rakuen Growlithe wrote:Out of curiosity, what makes an email address valid? Can you just give yourself one or does it need to be tied to a domain name?
If you are sending mail, this is where validity didn't count. However many mail servers now check that the domain at least is valid.

If you are receiving mail, your DNS zone file needs a MX record otherwise the internet doesn't know where to route the mail you intend to receive. So when you send a mail to your self-created mail server, you need to somehow bind it to the domain in question. For this reason, you need the MX field to be populated in your zone file.

This is why spam is so prolific. Due to the design, it is possible to spoof the sender field completely.

Re: HOWTO send email with your Raspberry Pi

Posted: Sun Mar 13, 2016 2:45 pm
by Valerion
Rakuen Growlithe wrote:Out of curiosity, what makes an email address valid? Can you just give yourself one or does it need to be tied to a domain name?
Here's the canonical answer:

https://tools.ietf.org/html/rfc5322#section-3.4.1
An addr-spec is a specific Internet identifier that contains a locally interpreted string followed by the at-sign character ("@", ASCII value 64) followed by an Internet domain.