klenwell information services : UbuntuCommandLineGmail

Revision history for UbuntuCommandLineGmail


Revision [3109]

Last edited on 2017-07-26 03:19:26 by KlenwellAdmin
Additions:
Gist: https://gist.github.com/tatwell/968a762038eaf6504807749c70bfad64
Deletions:
Source: [[http://code.google.com/p/klenwell/source/browse/trunk/projects/bash/mailx/setup_gmail_command_line.sh | setup_gmail_command_line.sh]]
Download: [[http://code.google.com/p/klenwell/downloads/detail?name=ubuntu_gmail_mailx-v11.10.sh | ubuntu_gmail_mailx-v11.10.sh]]


Revision [3028]

Edited on 2016-07-09 16:54:43 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
Source: [[http://code.google.com/p/klenwell/source/browse/trunk/projects/bash/mailx/setup_gmail_command_line.sh | setup_gmail_command_line.sh]]
Download: [[http://code.google.com/p/klenwell/downloads/detail?name=ubuntu_gmail_mailx-v11.10.sh | ubuntu_gmail_mailx-v11.10.sh]]
According to [[http://wiki.archlinux.org/index.php/Msmtp | archlinux.org]], Google is in the process of becoming it's own certificate authority and has switched to a "Google Certificate Authority" certificate rooted in Equifax.
Deletions:
Source: [[http://code.google.com/p/klenwell/source/browse/trunk/projects/bash/mailx/setup_gmail_command_line.sh setup_gmail_command_line.sh]]
Download: [[http://code.google.com/p/klenwell/downloads/detail?name=ubuntu_gmail_mailx-v11.10.sh ubuntu_gmail_mailx-v11.10.sh]]
According to [[http://wiki.archlinux.org/index.php/Msmtp archlinux.org]], Google is in the process of becoming it's own certificate authority and has switched to a "Google Certificate Authority" certificate rooted in Equifax.


Revision [2103]

Edited on 2012-02-19 14:51:50 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
Download: [[http://code.google.com/p/klenwell/downloads/detail?name=ubuntu_gmail_mailx-v11.10.sh ubuntu_gmail_mailx-v11.10.sh]]
$ gedit /tmp/ubuntu_gmail_mailx-v11.10.sh
$ chmod 755 /tmp/ubuntu_gmail_mailx-v11.10.sh
$ /tmp/ubuntu_gmail_mailx-v11.10.sh install
$ sudo apt-get install msmtp heirloom-mailx
Deletions:
Download: [[http://code.google.com/p/klenwell/downloads/detail?name=ubuntu_gmail_mailx-v1.0.sh ubuntu_gmail_mailx-v1.0.sh]]
$ gedit /tmp/ubuntu_gmail_mailx-v1.0.sh
$ chmod 755 /tmp/ubuntu_gmail_mailx-v1.0.sh
$ /tmp/ubuntu_gmail_mailx-v1.0.sh install
$ sudo apt-get install msmtp mailx


Revision [1836]

Edited on 2011-03-01 17:34:13 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
account gmail
account default : gmail
Deletions:
#account gmail
#account default : gmail


Revision [1441]

Edited on 2010-06-21 20:17:02 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
return to CategoryUbuntu
For the **nail** version of this script (which I prefer!), see UbuntuCommandLineGmailNail


Revision [1425]

Edited on 2010-05-30 09:46:06 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
$ ( cat /tmp/emailbody ; uuencode $TMP_ARCHIVE $FNAME ) | mailx -s "email test" $EMAIL_TO
Deletions:
$ ( cat /tmp/emailbody ; uuencode $TMP_ARCHIVE $FNAME) | mailx -s "email test" $EMAIL_TO


Revision [1424]

Edited on 2010-05-30 09:45:45 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
$ sudo apt-get install sharutils


Revision [1423]

Edited on 2010-05-30 09:45:02 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
===Usage===
Deletions:
===Usages===


Revision [1422]

Edited on 2010-05-30 09:44:33 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
===Usages===
Send a file with an attachment
$ EMAIL_TO=YOURNAME@gmail.com
$ echo "email test" > /tmp/emailbody
$ TMP_ARCHIVE=/tmp/some_archive
$ FNAME=$(basename $TMP_ARCHIVE)
$ ( cat /tmp/emailbody ; uuencode $TMP_ARCHIVE $FNAME) | mailx -s "email test" $EMAIL_TO
http://stackoverflow.com/questions/96326/korn-shell-code-to-send-attachments-with-mailx-and-uuencode/96636#96636


Revision [1419]

Edited on 2010-05-24 22:52:58 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
====Now Available: Install Script====
Source: [[http://code.google.com/p/klenwell/source/browse/trunk/projects/bash/mailx/setup_gmail_command_line.sh setup_gmail_command_line.sh]]
Download: [[http://code.google.com/p/klenwell/downloads/detail?name=ubuntu_gmail_mailx-v1.0.sh ubuntu_gmail_mailx-v1.0.sh]]
===Installation===
1. Download the script from http://code.google.com/p/klenwell/downloads/list. (Next steps assume you download it to dir ""<tt>/tmp</tt>"".
2. To completely automate installation, update your gmail settings at top of script:
$ gedit /tmp/ubuntu_gmail_mailx-v1.0.sh
3. Make script executable and run with ""<tt>install</tt>"" command:
$ chmod 755 /tmp/ubuntu_gmail_mailx-v1.0.sh
$ /tmp/ubuntu_gmail_mailx-v1.0.sh install
=====Manual Guide=====


Revision [1379]

Edited on 2010-05-13 22:48:29 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
++Install Thawte Certificate for Gmail++
Deletions:
++2. Install Thawte Certificate for Gmail++


Revision [1378]

Edited on 2010-05-13 22:48:11 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
If you don't have the certificate for some reason, you can download it in this package here: http://packages.ubuntu.com/en/source/lucid/ca-certificates


Revision [1377]

Edited on 2010-05-13 22:38:32 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
++2. Install Thawte Certificate for Gmail++
2. Configure msmtp
3. Configure mailx
4. Test
===++Install Certificate++===
===2. Configure msmtp===
===3. Configure mailx===
===4. Test===
Deletions:
2. Install Thawte Certificate for Gmail
3. Configure msmtp
4. Configure mailx
5. Test
===2. Install Certificate===
===3. Configure msmtp===
===4. Configure mailx===
===5. Test===


Revision [1376]

Edited on 2010-05-13 22:37:07 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
===2. Install Certificate===
According to [[http://wiki.archlinux.org/index.php/Msmtp archlinux.org]], Google is in the process of becoming it's own certificate authority and has switched to a "Google Certificate Authority" certificate rooted in Equifax.
This means you can user the existing certificate at ""<tt>/usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt</tt>"". Verify that that certificate exists and nothing else needs to be done at this step.
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
Deletions:
===2. Install Thawte Certificate===
This requires a Thawte certificate. The steps below assume that it is still available at the provided url. If not, you can create a file from the text included below.
$ mkdir -p ~/etc/.certs
$ chmod 0700 ~/etc/.certs
$ cd ~/etc/.certs
$ wget http://userweb.cs.utexas.edu/~suriya/UT-wireless/ThawtePremiumServerCA_b64.txt
The certificate, in all its glory:
-----BEGIN CERTIFICATE-----
MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkEx
FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYD
VQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlv
biBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhhd3RlIFByZW1pdW0gU2Vy
dmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZlckB0aGF3dGUuY29t
MB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYTAlpB
MRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsG
A1UEChMUVGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRp
b24gU2VydmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNl
cnZlciBDQTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNv
bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2aovXwlue2oFBYo847kkE
VdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIhUdib0GfQ
ug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMR
uHM/qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG
9w0BAQQFAAOBgQAmSCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUI
hfzJATj/Tb7yFkJD57taRvvBxhEf8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JM
pAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7tUCemDaYj+bvLpgcUQg==
-----END CERTIFICATE-----
source: http://userweb.cs.utexas.edu/~suriya/UT-wireless/ThawtePremiumServerCA_b64.txt
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA_b64.txt


Revision [1375]

Edited on 2010-05-13 22:27:36 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
http://wiki.archlinux.org/index.php/Msmtp


Revision [1373]

Edited on 2010-05-12 10:33:48 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
$ mailx -s "mailx gmail test" YOURNAME@gmail.com < /tmp/test_email
Deletions:
$ mailx -s "nail gmail test" YOURNAME@gmail.com < /tmp/test_email


Revision [1355]

Edited on 2010-05-11 14:19:17 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
=====Command Line Gmail Using msmtp/mailx=====
Deletions:
=====Command Line Gmail=====


Revision [1354]

Edited on 2010-05-11 12:17:20 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]

No Differences

Revision [1353]

Edited on 2010-05-11 12:16:54 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Deletions:
Command Line Email on Ubuntu (mailx version)
Posted on 3 March 2009, 8:53 pm, by klenwell, under Miscellany.
This guide explains how to configure Ubuntu so that you can send email from the command line using mailx with your Gmail account for delivery. This updates a guide I originally posted on the ubuntu forums for mailx, which is part of the current Ubuntu repositories (versions 7 and 8). To use nail, for which this guide was originally drawn up, see this post.
In 5 Fairly Easy Steps
1. Install the needed programs
$ sudo apt-get install msmtp
$ sudo apt-get install mailx
2. Install Thawte certificates for Gmail
EDIT: verisign.com apparently no longer issues certs at the address below. So the ‘wget’ step will not work. adkein, in a comment below (click here), links to another page when you can apparently get the needed cert. I cannot vouch for this as my cert still works. But you might try downloading that and putting it your ~/etc/.certs directory if you’re having issues finding the cert.
This is necessary for Gmail. (Thanks to laurentbois.com.)
$ wget https://www.verisign.com/support/thawte-roots.zip –no-check-certificate
$ unzip thawte-roots.zip
$ cp ‘Thawte Server Roots/ThawtePremiumServerCA_b64.txt’ ThawtePremiumServerCA.crt
This will open up a new msmtp configuration file
view plaincopy to clipboardprint?
1.
# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
2.
defaults
3.
logfile /tmp/msmtp.log
4.

5.
# gmail account
6.
#account gmail
7.
auth on
8.
host smtp.gmail.com
9.
port 587
10.
user YOURNAME@gmail.com
11.
password YOURPASSWORD
12.
from YOURNAME@gmail.com
13.
tls on
14.
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA.crt
15.

16.
# set default account to use (not necessary with single account)
17.
#account default : gmail
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA.crt
view plaincopy to clipboardprint?
1.
# set smtp for nail
2.
# ref: http://ubuntuforums.org/showpost.php?p=4531994&amp;amp;amp;amp;amp;amp;amp;amp;postcount=6
3.

4.
# gmail account (default)
5.
# $ mailx -s "subject line" -a /path/file recipient@email.com < /path/body.txt
6.
set from="YOURNAME@gmail.com (YOURNAME)"
7.
set sendmail="/usr/bin/msmtp"
8.
set message-sendmail-extra-arguments="-a gmail"
# set smtp for nail
# ref: http://ubuntuforums.org/showpost.php?p=4531994&amp;amp;amp;amp;amp;amp;amp;amp;postcount=6
# $ mailx -s "subject line" -a /path/file recipient@email.com < /path/body.txt
5. Run a test


Revision [1352]

Edited on 2010-05-11 12:15:29 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
Open mailx config file:
$ gedit ~/.mailrc
Copy the following lines and replace UPPERCASE text with your personal settings:
# set smtp for mailx
# gmail account (default)
# $ mailx -s "subject line" -a /path/attachment recipient@email.com < /path/body.txt
set from="YOURNAME@gmail.com (YOURNAME)"
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
Command Line Email on Ubuntu (mailx version)
Posted on 3 March 2009, 8:53 pm, by klenwell, under Miscellany.
This guide explains how to configure Ubuntu so that you can send email from the command line using mailx with your Gmail account for delivery. This updates a guide I originally posted on the ubuntu forums for mailx, which is part of the current Ubuntu repositories (versions 7 and 8). To use nail, for which this guide was originally drawn up, see this post.
In 5 Fairly Easy Steps
1. Install the needed programs
$ sudo apt-get install msmtp
$ sudo apt-get install mailx
2. Install Thawte certificates for Gmail
EDIT: verisign.com apparently no longer issues certs at the address below. So the ‘wget’ step will not work. adkein, in a comment below (click here), links to another page when you can apparently get the needed cert. I cannot vouch for this as my cert still works. But you might try downloading that and putting it your ~/etc/.certs directory if you’re having issues finding the cert.
This is necessary for Gmail. (Thanks to laurentbois.com.)
$ wget https://www.verisign.com/support/thawte-roots.zip –no-check-certificate
$ unzip thawte-roots.zip
$ cp ‘Thawte Server Roots/ThawtePremiumServerCA_b64.txt’ ThawtePremiumServerCA.crt
This will open up a new msmtp configuration file
view plaincopy to clipboardprint?
1.
# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
2.
defaults
3.
logfile /tmp/msmtp.log
4.

5.
# gmail account
6.
#account gmail
7.
auth on
8.
host smtp.gmail.com
9.
port 587
10.
user YOURNAME@gmail.com
11.
password YOURPASSWORD
12.
from YOURNAME@gmail.com
13.
tls on
14.
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA.crt
15.

16.
# set default account to use (not necessary with single account)
17.
#account default : gmail
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA.crt
$ gedit ~/.mailrc
Copy the following lines and replace UPPERCASE text with your personal settings:
view plaincopy to clipboardprint?
1.
# set smtp for nail
2.
# ref: http://ubuntuforums.org/showpost.php?p=4531994&amp;amp;amp;amp;amp;amp;amp;amp;postcount=6
3.

4.
# gmail account (default)
5.
# $ mailx -s "subject line" -a /path/file recipient@email.com < /path/body.txt
6.
set from="YOURNAME@gmail.com (YOURNAME)"
7.
set sendmail="/usr/bin/msmtp"
8.
set message-sendmail-extra-arguments="-a gmail"
# set smtp for nail
# ref: http://ubuntuforums.org/showpost.php?p=4531994&amp;amp;amp;amp;amp;amp;amp;amp;postcount=6
# gmail account (default)
# $ mailx -s "subject line" -a /path/file recipient@email.com < /path/body.txt
set from="YOURNAME@gmail.com (YOURNAME)"
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
5. Run a test
Send a test message to your gmail account:
$ echo -e "testing email from the command line" > /tmp/test_email
$ mailx -s "nail gmail test" YOURNAME@gmail.com < /tmp/test_email
Check your gmail account and you should have a message from yourself. You can also check your log:
$ tail /tmp/msmtp.log


Revision [1351]

Edited on 2010-05-11 12:10:56 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
Change permission on this file or msmtp will complain:
$ chmod 600 ~/.msmtprc


Revision [1350]

Edited on 2010-05-11 12:10:06 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
%%(bash)
%%(bash)
===3. Configure msmtp===
Create a new msmtp config file:
%%(bash)
$ gedit ~/.msmtprc
Copy the following lines. Replace UPPERCASE text with your personal settings:
# 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 YOURNAME@gmail.com
password YOURPASSWORD
from YOURNAME@gmail.com
tls on
tls_trust_file /home/USER/etc/.certs/ThawtePremiumServerCA_b64.txt
# set default account to use (not necessary with single account)
#account default : gmail
===4. Configure mailx===
===5. Test===
Deletions:
$ mv ThawtePremiumServerCA_b64.txt ThawtePremiumServerCA.crt


Revision [1349]

Edited on 2010-05-11 12:03:47 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
2. Install Thawte Certificate for Gmail
===2. Install Thawte Certificate===
This requires a Thawte certificate. The steps below assume that it is still available at the provided url. If not, you can create a file from the text included below.
$ mkdir -p ~/etc/.certs
$ chmod 0700 ~/etc/.certs
$ cd ~/etc/.certs
$ wget http://userweb.cs.utexas.edu/~suriya/UT-wireless/ThawtePremiumServerCA_b64.txt
$ mv ThawtePremiumServerCA_b64.txt ThawtePremiumServerCA.crt
The certificate, in all its glory:
-----BEGIN CERTIFICATE-----
MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkEx
FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYD
VQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlv
biBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhhd3RlIFByZW1pdW0gU2Vy
dmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZlckB0aGF3dGUuY29t
MB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYTAlpB
MRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsG
A1UEChMUVGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRp
b24gU2VydmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNl
cnZlciBDQTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNv
bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2aovXwlue2oFBYo847kkE
VdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIhUdib0GfQ
ug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMR
uHM/qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG
9w0BAQQFAAOBgQAmSCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUI
hfzJATj/Tb7yFkJD57taRvvBxhEf8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JM
pAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7tUCemDaYj+bvLpgcUQg==
-----END CERTIFICATE-----
source: http://userweb.cs.utexas.edu/~suriya/UT-wireless/ThawtePremiumServerCA_b64.txt
Deletions:
2. Install Certificate for Gmail


Revision [1348]

Edited on 2010-05-11 11:59:00 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
2. Install Certificate for Gmail
3. Configure msmtp
4. Configure mailx
5. Test


Revision [1347]

Edited on 2010-05-11 11:57:21 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
http://phosphorusandlime.blogspot.com/2008/05/ubuntu-command-line-email.html


Revision [1346]

Edited on 2010-05-11 11:56:41 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
1. Install Necessary Packages
===1. Install Necessary Packages===
%%
$ sudo apt-get install msmtp mailx
%%


Revision [1345]

Edited on 2010-05-11 11:53:29 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]
Additions:
http://ubuntuforums.org/showthread.php?t=780509


Revision [1344]

The oldest known version of this page was created on 2010-05-11 11:51:30 by KlenwellAdmin [Replaces old-style internal links with new pipe-split links.]