Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I set up mailx to send messages to my Gmail account? What I do now is run the command:

mail -s "hello kid" mymail@gmail.com

It freezes and does nothing. I tried some variations, but all of them just froze dead in my terminal. Is there anything I need to configure in mailx before actually using mail?

There were different options found on the Internet, like making a .mailrc and other config files, but I got nowhere. Can someone provide me with more information on the subject?

share|improve this question
    
I suspect it's exactly as complex as the guides you found told you it was. You the user think "just send email to gMail", but behind the scenes you have to deal with encryption, authentication, remote server addresses, protocol choices... All of that is exposed to you when you insist on using an old-school client like mailx. If you want a console mail program but would rather not pay attention to so many details, surely alpine or mutt would be easier to make work with gMail? –  Warren Young Mar 28 '12 at 19:16
    
I used alpine for some time and liked it. –  eeer Mar 29 '12 at 4:17
add comment

2 Answers

up vote 6 down vote accepted

The command mail -s "hello kid" mymail@gmail.com is waiting for you to type the mail message and then control-d. After you do that the message will be sent. If you just want a quick test, do:

echo `date` this is a test | mail mymail@gmail.com

and the message will be sent immediately.

share|improve this answer
    
thanks, it works now. And I was wondering why was it hanging) –  eeer Mar 29 '12 at 4:14
add comment

You can also redirect a file to mail.
Useful when sending mail via cron

mail -s "Logs" mymail@gmail.com < /var/log/auth.log

share|improve this answer
    
yes, thanks for the tip –  eeer Mar 29 '12 at 4:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.