Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: gavinmc42 on October 21, 2014, 12:43:31 AM

Title: Sending emails
Post by: gavinmc42 on October 21, 2014, 12:43:31 AM
Hi Guys,

Anyone know know how to send emails in TC?
Normally Busybox has sendmail built-in, but not in the 1.22.1 RPi version!

Been using Python but that means I need to install it and all it's dependencies.
There is Claws-mail and Fetchmail but these are clients?

It is for an embedded application and I want to send emails twice a day and also if an alarm condition occurs.
Was thinking it could be a simple cron job calling bash scripts.
Title: Re: Sending emails
Post by: Lee on October 21, 2014, 01:41:29 AM
Quote
Anyone know know how to send emails in TC?

On the x86 platform, I wrote a little console mail utility script ('mx", the "mail experiment") that uses something like the following:
Code: [Select]
mailx -n -v -r <senderemail@domain.com> -s "<mail subject>" -S smtp-auth-user=<senderemail@domain.com> -S <senderssmtppassword> -S smtp=<smtp.domain.com:587> <recipient@domain.net>
It requires mailx.tcz and, I think, msmtp.tcz

Sending was an afterthought as my script was mainly for reading mail from a pop3 server, so the sending capability isn't all that polished.  It takes the message body from stdin, so you'd have to use redirection to use it in a script... or read up on the mailx command line options - I'm sure there's one to take the message body from a file.  At some point I'll look into it further as sending mail from a script is on my todo list, but it won't be this week, and probably not any time really soon.
Title: Re: Sending emails
Post by: bmarkus on October 21, 2014, 01:45:26 AM
At the moment no MTP in the repo. I will add one, msmtp and/or nullmailer in the next days.
Title: Re: Sending emails
Post by: bmarkus on October 21, 2014, 05:00:29 AM
msmtp.tcz added to repo
Title: Re: Sending emails
Post by: Greg Erskine on October 21, 2014, 05:16:38 PM
msmtp.tcz added to repo

Thanks bmarkus  :D

Code: [Select]
$ msmtp --help
msmtp: error while loading shared libraries: libgsasl.so.7: cannot open shared object file: No such file or directory

Is there a dependency missing? I'm using piCorePlayer if that matters.

regards
Greg
Title: Re: Sending emails
Post by: Rich on October 21, 2014, 08:47:21 PM
Hi Greg Erskine
Is there a  libgsasl.tcz  in the repository?
Title: Re: Sending emails
Post by: bmarkus on October 22, 2014, 01:27:44 AM
Hi Greg Erskine
Is there a  libgsasl.tcz  in the repository?

Yes it is there. Somehow the msmtp.tcz.dep file is missing, I will fix it. Load libgsasl.tcz manuall from the repo.
Title: Re: Sending emails
Post by: Greg Erskine on October 22, 2014, 02:51:16 AM
Yes it is there. Somehow the msmtp.tcz.dep file is missing, I will fix it. Load libgsasl.tcz manuall from the repo.

Thanks. That fixed it.
Title: Re: Sending emails
Post by: gavinmc42 on November 06, 2014, 01:47:51 AM
Must be doing something wrong.

Copied msmtp + libgsasl + libidn files into the tce/optional directory.
Added a msmtp.tcz.dep file to include libgsasl
Put msmtp.tcz into onboot
msmtp still says "error while loading libgsasl.so.7: ....

Used 7-zip to check the tcz files in Windows to find out where their go in TC. /usr/local/bin etc
Seem to be were they are supposed to be.

libidn.tcz does not seem to be an archive, 7-zip tells me?
Title: Re: Sending emails
Post by: bmarkus on November 06, 2014, 01:59:12 AM

Used 7-zip to check the tcz files in Windows to find out where their go in TC. /usr/local/bin etc
Seem to be were they are supposed to be.

libidn.tcz does not seem to be an archive, 7-zip tells me?

.tcz files are squash files, 7zip do not knows them. Use linux to uncompress, looopmount them or better to use TC app browsers, like 'tce' in a terminal window to get list of their content.

Please read the Core book http://distro.ibiblio.org/tinycorelinux/corebook.pdf

Title: Re: Sending emails
Post by: gavinmc42 on November 06, 2014, 02:27:35 AM
Hi bmarkus,

My TC RPi's are on a device network behind a firewall.
So I'm doing everything via ssh and sftp.

Only use Windows 7-Zip to check *.tcz files on my Tinycore folder.

Command line mail out I thought would be easy as sys admins have been doing it since year dot.
I think they use sendmail now?

google example

echo "$line" | mail -s subject "$email"

http://theos.in/shell-scripting/send-mail-bash-script/
http://superuser.com/questions/384499/how-is-mail-actually-sent-when-i-use-the-linux-mail-command

The trick with RPi TC is to find what is already in the tcz mirror that can do what I want.

Title: Re: Sending emails
Post by: gavinmc42 on November 06, 2014, 03:13:36 AM
Busybox has a utility ssmtp
http://www.busybox.net/tinyutils.html
Got the armhf.deb and tried the binary but got bitten by missing library.

Think I need to figure out how to make tcz from armhf.debs for the RPi.



Title: Re: Sending emails
Post by: bmarkus on November 06, 2014, 03:32:34 AM
Busybox has a utility ssmtp
http://www.busybox.net/tinyutils.html
Got the armhf.deb and tried the binary but got bitten by missing library.

Think I need to figure out how to make tcz from armhf.debs for the RPi.

Better to build it on piCore instead of playing with 3rd-party imported packages. Also, msmtp is in the repo and it works. Try.
Title: Re: Sending emails
Post by: gavinmc42 on November 06, 2014, 08:09:42 PM
I did try msmtp but I had to manually install it, didn't work
Will try normal tce-load once I get past the firewall.
Title: Re: Sending emails
Post by: gavinmc42 on November 07, 2014, 01:04:20 AM
OK internet connected
using ozzie mirror  tinycore.mirror.uber.com.au

msmtp.tcz , libgsasl, libidn installed
tried sending emails,
got message need libiconv.tcz - ouch 1.2MB

Expanded partition to 20MB
tried tce-load -wi libiconv.tcz and got checksum did not match

now what?

learning lots:)
Title: Re: Sending emails
Post by: gavinmc42 on November 13, 2014, 03:31:54 AM
Found this method, so old is has spiderwebs

http://www.geekride.com/tech-tip-sending-email-from-command-line/

telnet  and nc are in busy box, cool

Title: Re: Sending emails
Post by: bmarkus on November 13, 2014, 03:49:24 AM
You can use Python also to make your own sending apps.