WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] Suggest an email program please.  (Read 9909 times)

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
[SOLVED] Suggest an email program please.
« on: May 18, 2012, 04:37:21 AM »
Hi,

I am using Calibre to generate news e-books files on my TC server and would like to automatically send the completed file by email to a recipient when complete or at a specific time.

Could someone recommend a email program (from the many available!) that would be suitable to easily send this file to a specified email address. I do not need to receive email just send in some scripted manner.

Would someone suggest a good email package to try? Thank you
« Last Edit: May 20, 2012, 12:21:51 AM by b1ackmai1er »

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7795
Re: Suggest an email program please.
« Reply #1 on: May 18, 2012, 06:55:23 AM »
Hi b1ackmai1er
Remus is looking to send emails using shell scripts, he is in the process of updating mutt:
http://forum.tinycorelinux.net/index.php/topic,12787.msg70001.html#msg70001

Offline gutmensch

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • I can make it disappear, have no fear!
    • remembrance blog
Re: Suggest an email program please.
« Reply #2 on: May 19, 2012, 01:25:42 AM »
I submitted mailx to the repository, formerly known as "nail", which can also be used to send mails from shell scripts without the need for local smtp relaying or serving, e.g.
Code: [Select]
mailx -r “myaddress@something.com” -s “Some subject” -S smtp=some.smtp.server info@company.com < msg.txt
reference: http://forums.fedoraforum.org/showthread.php?t=143690
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: Suggest an email program please.
« Reply #3 on: May 19, 2012, 09:44:15 AM »
Thanks guys, I will try mailx and if I get nowhere with that I will buzz Remus.

Cheers.

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: Suggest an email program please.
« Reply #4 on: May 19, 2012, 10:21:11 PM »
Thanks guys I have mailx working.

Am surprised how big a package install you need just to send an e-mail!

regards Phil

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: Suggest an email program please.
« Reply #5 on: May 19, 2012, 11:06:11 PM »
@gutmensch

Hi, I managed to get mailx working with my internet provider mail account but am stuck on getting it to work with gmail

My  command is :

Code: [Select]
mailx -v -r account@gmail.com -s 'mail test' -a /mnt/sdc1/uploads/attachement.zip -S smtp=smtp.gmail.com account@gmail.com </mnt/sdc1/uploads/message.txt

but I get the error:

Code: [Select]
530 5.7.0 Must issue a STARTTLS command first. rv5sm18561052pbc.56
smtp-server: 530 5.7.0 Must issue a STARTTLS command first. rv5sm18561052pbc.56

The documentation

http://heirloom.sourceforge.net/mailx/mailx.1.html#16

indicates I need to set the environment variable

Code: [Select]
smtp-use-starttls

But I cannot work out how to do this. I have tried:

Code: [Select]
set smtp-use-starttls=""
But it does not work. could anyone suggest anything?

Thankyou


Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: Suggest an email program please.
« Reply #6 on: May 19, 2012, 11:55:14 PM »
tried export command instead of set:

export MAILRC=smtp-use-starttls

and

export MAILRC=smtp-use-starttls=yes

and

export MAILRC="/dev/null smtp-use-starttls=yes" (with and with =yes)

but still getting must issue start ttls command first.

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
[SOLVED] Suggest an email program please.
« Reply #7 on: May 20, 2012, 12:21:22 AM »
Finally got it to work thanks to this page

http://fclose.com/b/linux/1411/sending-email-from-mailx-command-in-linux-using-gmails-smtp/

Code: [Select]
mailx -n -v -r account@gmail.com -s 'test' -a /mnt/sdc1/uploads/attachment.zip -S smtp-auth-user=account@gmail.com -S smtp-use-starttls -S ssl-verify=ignore -S smtp-auth=login -S smtp-auth-password=mypassword -S smtp=smtp.gmail.com account@gmail.com < /mnt/sdc1/uploads/message.txt

Regards Phil

Offline gutmensch

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • I can make it disappear, have no fear!
    • remembrance blog
Re: [SOLVED] Suggest an email program please.
« Reply #8 on: May 20, 2012, 12:44:29 AM »
nice work :) AFAIR you can set the environment variables for mailx/nail in the /usr/local/etc/nail.rc file. so if you would put in it
Code: [Select]
set smtp-use-starttls
it should work, even for all other parameter you mentioned above.


[edit]
about the size:
yes, postfix is bit of a monster because of its dependencies, one could possibly find a lighter *bin/sendmail provider like msmtp, I'll check and create an extension :)
[/edit]
« Last Edit: May 20, 2012, 12:54:06 AM by gutmensch »
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline gutmensch

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • I can make it disappear, have no fear!
    • remembrance blog
Re: [SOLVED] Suggest an email program please.
« Reply #9 on: May 20, 2012, 02:07:54 AM »
Uploaded msmtp and updated mailx dep to not automatically use postfix. Info file indicates the need of sendmail and leaves the choice between msmtp.tcz and postfix.tcz ;)
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10221
Re: [SOLVED] Suggest an email program please.
« Reply #10 on: May 20, 2012, 02:22:55 AM »
If looking for a smaller package, I think busybox sendmail would work too (standalone). Note I don't think it supports SSL so not for gmail.
The only barriers that can stop you are the ones you create yourself.

Offline herrMnnn

  • WikiUser
  • *
  • Posts: 33
Re: [SOLVED] Suggest an email program please.
« Reply #11 on: May 25, 2012, 06:45:01 PM »
I figure this is simple stuff for most forum members, but as a newbie this as taken me hours to research and solve.

I spent some time trying to get msmtp working with a gmail account, so thought I'd share what I've found and what now works for me.

NB I have a minimal Core system with no GUI, and so I do not have firefox installed as per the directions in the above link.

With msmtp and mailx extensions installed,

Created .msmtprc file in home directory and edited as follows:

Code: [Select]
account default
host smtp.gmail.com
port 587
protocol smtp
auth on
from myaddress@gmail.com
user myaddress
password mypassword
tls on
tls_starttls on
tls_trust_file /home/tc/Equifax_Secure_Certificate_Authority.cer

I ran chmod 0600 on this file after creating it 'cos I read somewhere that I should.  Not sure how secure this all is as the file contains my password in clear text?

My main problem was finding a valid tls_trust_file, so I eventually found and downloaded one:

Code: [Select]
wget http://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.cer
I don't understand this certificate stuff but it works - please chime in if I am opening my system up to spammers...

I then created a .mailrc file in my home directory, and edited as follows:

Code: [Select]
account gmail {
set smtp-use-starttls
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=myaddress@gmail.com
set smtp-auth-password=mypassword
set from="myaddress@gmail.com"
}

Did a chmod 0600 on that file too for what it's worth...

I can now send emails via my gmail account:

to just send a message from a script:
Code: [Select]
tc@box:~$ echo "This is the message body" | mailx -A gmail -s "This is the  message Subject" sendtoaddress@isp.com.au
or to send a log file in the message body
Code: [Select]
tc@box:~$ cat somelogfile | mailx -A gmail -s "somelogfile in body :-)" sendtoaddress@isp.com.au
Can someone confirm if this setup is ok or otherwise, specifically with regards to security?  I am the only user of this system, which has passwords setup but still uses autologin, and has remote access via SSH.

Cheers

Tim

Offline herrMnnn

  • WikiUser
  • *
  • Posts: 33
Re: [SOLVED] Suggest an email program please.
« Reply #12 on: May 25, 2012, 09:10:16 PM »
of course it's not quite that straight forward...   ::)

while the above works in my user account, I want to send an email whenever the system reboots.  Putting the above mailx commands in /opt/bootlocal.sh doesn't work, presumably because it isn't accessing the config files in my /home/tc directory.

I copied the .msmtprc file and the certificate into /usr/local/etc and edited the .msmtprc to reflect the path to this certificate. I also changed the ownership of both files to root.  There was already a nail.rc config file there so I edited that to include the settings from my .mailrc file.  I then added the extra files to /opt/.filetool.lst, ran a backup and rebooted.

Email is now sent at boot time as required.   :)

Offline gutmensch

  • Administrator
  • Hero Member
  • *****
  • Posts: 606
  • I can make it disappear, have no fear!
    • remembrance blog
Re: [SOLVED] Suggest an email program please.
« Reply #13 on: May 26, 2012, 12:26:48 AM »
looks good, I also added the gmail case without verifying/trusting of the server to the info file as an example, but yours is absolutely complete I'd say :)

@bootlocal.sh:
this script is run as root, but you can still run commands as a user like
Code: [Select]
su -c '/opt/sendbootmail.sh' tc

@/usr/local/etc/nail.rc, ~/.mailrc
the configuration naming is a bit crazy in mailx... in the Makefile they default to a global file nail.rc (maybe for compatibility) and within user context the file is named ~/.mailrc, I think I will clear this up in the next build.
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10221
Re: [SOLVED] Suggest an email program please.
« Reply #14 on: May 26, 2012, 01:58:09 AM »
Looks good, I didn't see anything obvious wrong in that setup.
The only barriers that can stop you are the ones you create yourself.