LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command Line Email (gmail) setup (https://www.linuxquestions.org/questions/linux-newbie-8/command-line-email-gmail-setup-833035/)

Ubunoob001 09-18-2010 09:44 AM

Command Line Email (gmail) setup
 
Hey all, Im pretty new to C.L.I/text editing work. So maybe its a bit old-fashioned but Im interested in learning how to send email via the command line. I am running 10.04 32 bit

Situation: I have followed the explicit and step-by-step actions at http://klenwell.com/is/UbuntuCommandLineGmail

Question: Upon completion, when trying to send a test email to myself via gmail (from CLI) I get the following error: "msmtp: no recipients found". In CLI below it asks me to explicitly pick a mailx to download. I think I already have mailx as when I type mailx I get "no mail for primary".

Thanks in advance!

Here is my work
Code:

:~$ sudo apt-get install msmtp mailx
[sudo] password for:
Reading package lists... Done
Building dependency tree     
Reading state information... Done
msmtp is already the newest version.
Package mailx is a virtual package provided by:
  mailutils 1:2.1+dfsg1-4ubuntu1
  heirloom-mailx 12.4-1.1
  bsd-mailx 8.1.2-0.20090911cvs-2ubuntu1
You should explicitly select one to install.
E: Package mailx has no installation candidate
:~$ gedit ~/.msmtprc
:~$ chmod 600 ~/.msmtprc
:~$ gedit ~/.mailrc
:~$ echo -e "testing email from the command line" > /tmp/test_email
:~$ mailx -s "mailx gmail test" xxxxxxx@gmail.com < /tmp/test_email
msmtp: no recipients found

here is ~/.msmtprc
Code:

# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
defaults
logfile /tmp/msmtp.log

# gmail account
#account gmail
auth on
host smtp.gmail.com
port 587
user xxxxxx@gmail.com
password xxxxxx
from xxxxxx@gmail.com
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt

# set default account to use (not necessary with single account)
#account default : gmail

and here is ~/.mailrc
Code:

  # set smtp for mailx

# gmail account (default)
# $ mailx -s "subject line" -a /path/attachment recipient@email.com < /path/body.txt
set from="xxxxxx@gmail.com (xxxxx)"
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"


netmar 09-18-2010 10:20 AM

Unless your CLI environment lacks even rudimentary terminal encoding (like vt100), you may want to consider using a more capable email client than mailx.

You could try using alpine (just sudo apt-get install alpine -- I think it's in universe). It's the successor to the old pine email client, and is probably the easiest cli email client you'll find.

It's also about as full-featured as you could want, including a method to store the config on your IMAP server so that all your alpine configs(if you run it on different machines) can be updated at once. Setting up the client is pretty straightforward, too. Just use the arrow keys to navigate to SETUP, press enter, and press C for config. You'll get a long list of options, and there are prompts at the bottom of the page that list the available commands.

There are other options for a cli email client including my personal favorite mh, which integrates with the command line, but none that are easier to use.

Ubunoob001 09-18-2010 12:33 PM

Quote:

Originally Posted by netmar (Post 4101791)
Unless your CLI environment lacks even rudimentary terminal encoding (like vt100), you may want to consider using a more capable email client than mailx.

You could try using alpine (just sudo apt-get install alpine -- I think it's in universe). It's the successor to the old pine email client, and is probably the easiest cli email client you'll find.

It's also about as full-featured as you could want, including a method to store the config on your IMAP server so that all your alpine configs(if you run it on different machines) can be updated at once. Setting up the client is pretty straightforward, too. Just use the arrow keys to navigate to SETUP, press enter, and press C for config. You'll get a long list of options, and there are prompts at the bottom of the page that list the available commands.[...]

Great thanks so much for the suggestion! Any thoughts on why my mailx setup failed? I may head back here with an alpine question in a bit. Thanks again!

prayag_pjs 09-18-2010 01:16 PM

One cant send mail until and unless you give smtp server name to any email client...
You can send mail from your linux system if its server and supports relaying...

check for postfix or sendmail service running on your system or not and try sending mail from your CLI on command prompt itself

$mail -s "testmail" ........

Ubunoob001 09-18-2010 08:59 PM

Thanks Netmar
 
Quote:

Originally Posted by netmar (Post 4101791)
Unless your CLI environment lacks even rudimentary terminal encoding (like vt100), you may want to consider using a more capable email client than mailx.

You could try using alpine (just sudo apt-get install alpine -- I think it's in universe). It's the successor to the old pine email client, and is probably the easiest cli email client you'll find.

It's also about as full-featured as you could want, including a method to store the config on your IMAP server so that all your alpine configs(if you run it on different machines) can be updated at once. Setting up the client is pretty straightforward, too. Just use the arrow keys to navigate to SETUP, press enter, and press C for config. You'll get a long list of options, and there are prompts at the bottom of the page that list the available commands.

There are other options for a cli email client including my personal favorite mh, which integrates with the command line, but none that are easier to use.

Alpine is exactly what I was looking for! Many thanks


All times are GMT -5. The time now is 07:40 PM.