Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to get my hands on a good command line email tool for Ubuntu so that I can send simple emails may be even attach files through the terminal or simple bash scripts. My ssmtp.conf file looks something like this right now:

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=myusername@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=smtp.gmail.com:587

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

# The full hostname
hostname=myusername@gmail.com
AuthUser=myusername
AuthPass=mypassword
UseSTARTTLS=YES 
# 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

I also added alias in the revaliases file as follows:

root:myusername@gmail.com:smtp.gmail.com:587
localusername:myusername@gmail.com:smtp.gmail.com:587

I am behind a proxy server which works when i set an automatic proxy configuration URL and my system proxy settings are set according to the automatic proxy configuration URL.

However when I run sSMTP from terminal using:

sudo ssmtp someone@example.com
hello world 

Then pressing ctrl+d, I get:

ssmtp: Cannot open smtp.gmail.com:587

The title is the question.

share|improve this question
add comment

1 Answer

mailhub=smtp.gmail.com:465

The port is wrong. Your aliases need updating too.

Gmail only really allows SSL emails from remote hosts, other connections usually don't work. Enable SSL and use port 465.

If that doesn't work verify connectivity with telnet:

telnet smtp.gmail.com:465 it should work, and return gibberish.

share|improve this answer
    
Thanks for your reply @coteyr, I changed the port to 465 but get this error Cannot open smtp.gmail.com:465 and I tried telnet smtp.gmail.com it says network unreachable . So i think it is a connectivity issue. Am i missing some certificates that need to be installed or is the proxy? how do i resolve it? –  Vivek Pradhan Jan 22 '13 at 18:11
    
it is possible that your network configuration does not allow any traffic that does not go though the proxy. I have seen a few setups like that. Network Unreachable means that it can't get to smtp.gmail.com at all, and has nothing to do with SMTP or proxy. Check your default route, and try tracert smtp.gmail.com You may need to install it. –  coteyr Jan 22 '13 at 18:32
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.