Linux Tips and Tricks

Linux Tips and Tricks

Sending email via gmail in linux

September19

Sending email via gmail in linux

1) Make sure you have Heirloom mailx. How to test it ?
simply enter the below code in your command prompt

1
2
3
$mailx -v
mail: invalid option -- v
Try `mail --help' or `mail --usage' for more information.

If you get the above error message, then you need to install the Heirloom mailx.

2) How to install it ? (i am using ubuntu)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ sudo apt-get install heirloom-mailx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgsasl7 libmailutils2 libntlm0
................
.............
................
The following packages will be REMOVED:
mailutils
The following NEW packages will be installed:
heirloom-mailx
................

3) Once the package is installed, check whether you have any file called .mailrc in your home directory.

1
2
$ ls -l ~/.mailrc
ls: cannot access /home/kamaraj/.mailrc: No such file or directory

4) If you have any file, then just open and put the below contents. Otherwise create a new file called .mailrc

1
2
3
4
5
6
7
8
account gmail {
set smtp-use-starttls
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=abcd@gmail.com
set smtp-auth-password=mypassword
set from="ABCD "
}

5) Just change the contents of the below lines.

1
2
3
set smtp-auth-user=YOUR-GMAIL-ID
set smtp-auth-password=YOUR-GMAIL-PASSWORD
set from="NAME"

6) Its the time to test. Now trigger the below command from your command prompt.

1
 
1
2
3
4
5
6
7
8
9
10
11
$ echo "Test Email" | mailx -v -A gmail -s "test" yyyyyyyy@gmail.com
Resolving host smtp.gmail.com . . . done.
Connecting to 74.125.45.109 . . . connected.
250 2.0.0 OK 1316447647 s8sm2760907ani.3
 
...............
............
............
 
 >>> QUIT
 221 2.0.0 closing connection s8sm2760907ani.3

7) Now check your gmail inbox (sent items).

posted under Uncategorized

Email will not be published

Website example

Your Comment:


Recent Comments

    Categories