dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Client email to send emails from command line

Sat Mar 25, 2017 9:50 pm

Hello,

Can you please advise a client email to send emails from command line without installing any heavy server on my Raspbian Jessie light?

I simply need it to send me reports on the status of the server.

Thank you so much, daniele

User avatar
DougieLawson
Posts: 36164
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:05 pm

sudo apt-get install mailtools

echo 'Test stuff' | mailx -s 'Test email' someone@example.co.uk


My system has postfix configured and running, you may need that to act as a MTA relay.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:07 pm

DougieLawson wrote:sudo apt-get install mailtools

echo 'Test stuff' | mailx -s 'Test email' someone@example.co.uk


My system has postfix configured and running, you may need that to act as a MTA relay.
Thanks, is it a client or a mail server?

User avatar
DougieLawson
Posts: 36164
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:08 pm

Eh?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:14 pm

I mean, does it install a mail server or is it just a SMTP client?

I am looking for an application with no impact on the system load,
Thanks

User avatar
DougieLawson
Posts: 36164
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:20 pm

mailtools gives you the mail and mailx commands, nothing more.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:21 pm

DougieLawson wrote:mailtools gives you the mail and mailx commands, nothing more.
So it does not install anything running continuously?

User avatar
DougieLawson
Posts: 36164
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:25 pm

You won't get a long running mail daemon until you install & configure postfix or sendmail (or equivalent). I like postfix because it's easy to configure (unlike sendmail) and it just chuggs along using minimal resources.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Re: Client email to send emails from command line

Sat Mar 25, 2017 10:28 pm

Clear, thanks


pcmanbob
Posts: 6957
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Client email to send emails from command line

Sun Mar 26, 2017 9:40 am

Hi.

If you are happy using a gmail account ( I set one up specifically for my Pi )
then you can use ssmtp and mailutils.

mailutils will allow you to send attached file with your mail.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Re: Client email to send emails from command line

Sun Mar 26, 2017 10:49 am

pcmanbob wrote:Hi.

If you are happy using a gmail account ( I set one up specifically for my Pi )
then you can use ssmtp and mailutils.

mailutils will allow you to send attached file with your mail.
Hi is ssmtp already installed in Jessie light or has to be installed?

pcmanbob
Posts: 6957
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Client email to send emails from command line

Sun Mar 26, 2017 11:07 am

dcaccount wrote:
Hi is ssmtp already installed in Jessie light or has to be installed?
No you have to install both.

Code: Select all

sudo apt-get install ssmtp
sudo apt-get install mailutils
if you want help setting it up just ask.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Re: Client email to send emails from command line

Sun Mar 26, 2017 11:35 am

pcmanbob wrote:
dcaccount wrote:
Hi is ssmtp already installed in Jessie light or has to be installed?
No you have to install both.

Code: Select all

sudo apt-get install ssmtp
sudo apt-get install mailutils
if you want help setting it up just ask.
Clear, thanks for helping, daniele

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Client email to send emails from command line

Mon Jan 01, 2018 3:29 pm

1.1.2018




RPI 3 using the latest Stretch updates

I installed ssmtp and mailutil and set the conf file - see below.

I keep getting mail: cannot send message: Process exited with a non-zero status

I even changed gmail to "accept less secure applications" but still cannot send the email

I can not seem to find a log file but I do get a dead.letter file

Any further help on this?????

ssmtp.conf contents:
#

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#root=postmaster
root=


# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=host2
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES
AuthUser=me@gmail.com
AuthPass=mypw
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES

pcmanbob
Posts: 6957
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Client email to send emails from command line

Mon Jan 01, 2018 3:45 pm

Looking at your configure info.
You are missing the line UseTLS=YES

This is my config file with your info in it for account etc.

Code: Select all

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=me@gmail.com

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub=smtp.gmail.com:587

AuthUser=me@gmail.com
AuthPass=mypw
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=gmail.com

# The full hostname
hostname=host2

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=yes
also worth logging in to gmail from web browser and see if the is an email in there alerting you to a new device using your account yet another new security feature of gmail.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

sparkie777
Posts: 121
Joined: Tue Nov 27, 2012 4:37 am

Re: Client email to send emails from command line

Mon Jan 01, 2018 4:12 pm

anybody who needs a really simple and secure relay-only mail transport agent?

then you want to install:

Code: Select all

apt install nullmailer
probably the most lightweight SMTP server ever :-)

it provides a 'sendmail'-compatible command line interface though.

An example how to send an email from the shell command line:

Code: Select all

sendmail -oi -f aaa@domain1.com bbb@domain2.com << !
From: ccc@domain3.com
To: ddd@domain4.com                                   
Subject: test

mail body data
!

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Client email to send emails from command line

Tue Jan 02, 2018 1:18 pm

pcmanbob wrote:
Mon Jan 01, 2018 3:45 pm
Looking at your configure info.
You are missing the line UseTLS=YES

This is my config file with your info in it for account etc.

Code: Select all

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=me@gmail.com

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub=smtp.gmail.com:587

AuthUser=me@gmail.com
AuthPass=mypw
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=gmail.com

# The full hostname
hostname=host2

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=yes
also worth logging in to gmail from web browser and see if the is an email in there alerting you to a new device using your account yet another new security feature of gmail.
2.1.2018
Firstly many thanks for your reply.
I copied your conf file into mine and changed the gmail values to my name + PW but am still getting the same error.
So there seem still to be a gmail sign-on problem - even with my google set to less secure applications.
Logging in to gmail with my PW and got signed on but nothing in my input box.
There is nothing in /var/log/mail.log

So now I am really stuck.

BD

pcmanbob
Posts: 6957
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Client email to send emails from command line

Tue Jan 02, 2018 1:39 pm

OK one last thing to check your gmail password must only contain letters a-z upper and lower case and numbers 0-9.

you must no use any special characters ssmtp does not send them correctly.

I know gmail still works with ssmtp as I have 2 pis sending emails daily and a zero that send me its IP every time it boots all this is on 2 different gmail accounts, so there must be an error in your set up.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Client email to send emails from command line

Tue Jan 02, 2018 8:44 pm

pcmanbob wrote:
Tue Jan 02, 2018 1:39 pm
OK one last thing to check your gmail password must only contain letters a-z upper and lower case and numbers 0-9.

you must no use any special characters ssmtp does not send them correctly.

I know gmail still works with ssmtp as I have 2 pis sending emails daily and a zero that send me its IP every time it boots all this is on 2 different gmail accounts, so there must be an error in your set up.

Ah, there we have it. My password does contain special characters ...
I'll create a new email address and a new password.
I wonder would work using a different provider than Gmail.
Many thanks

BD

pcmanbob
Posts: 6957
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Client email to send emails from command line

Wed Jan 03, 2018 1:11 am

Yes the Gmail accounts I used for my pi's I set up special just for them using long random letter/number passwords but without any special characters.

People have asked about using other email providers but I have never tried you would need to be able to find all the relevant settings to enter in to the config file.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
bonzadog
Posts: 236
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Client email to send emails from command line

Thu Jan 04, 2018 8:55 am

After creating a new account with a password in the form of abcd1234
and a password of type efgh1234 and allow the new account to use less than secure apps
I am still getting the "..exit with non zero code...." and an error in the /mail/log to that effect.

I wonder if postfix would be a better solution I would like to be able to receive mails too.
I'll probably need help in setting postfix up since I have not much experience in setting up emails.

User avatar
DougieLawson
Posts: 36164
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Client email to send emails from command line

Thu Jan 04, 2018 10:10 am

I'm a fan of postfix, it's easy to install and the configuration choices (during installation) suit most folks basic needs.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

pcmanbob
Posts: 6957
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Client email to send emails from command line

Thu Jan 04, 2018 1:38 pm

bonzadog wrote:
Thu Jan 04, 2018 8:55 am
After creating a new account with a password in the form of abcd1234
and a password of type efgh1234 and allow the new account to use less than secure apps
I am still getting the "..exit with non zero code...." and an error in the /mail/log to that effect.

I wonder if postfix would be a better solution I would like to be able to receive mails too.
I'll probably need help in setting postfix up since I have not much experience in setting up emails.
If you want to receive mails as well then ssmtp is not what you need its only for sending.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
RDK
Posts: 262
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Client email to send emails from command line

Tue Aug 13, 2019 5:48 am

I'm also trying, without success, to set up my Pi (V3 running Stretch) to send me a message once a day. I have basically followed this procedure:

Code: Select all

sudo apt-get install ssmtp
sudo apt-get install mailutils

sudo nano /etc/ssmtp/ssmtp.conf
Here is my conf file:

Code: Select all

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=MyPi

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
AuthUser=Me.Pi@gmail.com
# only nimbers and/or letters, no special characters
AuthPass=1234abcd
FromLineOverride=YES
UseSTARTTLS=YES
UseTLS=YES
Debug=YES
I run this command line :
echo "Hello world email body" | mail -s "Test Subject" me@hotmail.com
and I get this error message:
mail: cannot send message: Process exited with a non-zero status
I have enabled the G-Mail option to allow "less secure apps"

My system is a Raspberry Pi V3 running Stretch, recently updated/upgraded.

I see that I'm not the only one having this issue, I hope someone can help.....RDK

Return to “Raspbian”