Connect to SMTP server using STARTTLS

openssl s_client -starttls smtp -crlf -connect 127.0.0.1:25
Allows you to connect to an SMTP server over TLS, which is useful for debugging SMTP sessions. (Much like telnet to 25/tcp). Once connected you can manually issue SMTP commands in the clear (e.g. EHLO)
Sample Output
$ openssl s_client -starttls smtp -crlf -connect smtp1.google.com:25
CONNECTED(00000003)
depth=1 /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
verify error:num=19:self signed certificate in certificate chain
verify return:0
---
Certificate chain
<...>
---
220 smtp.google.com ESMTP

7
By: realist
2009-08-19 08:37:24

These Might Interest You

  • This command will start a simple SMTP server listening on port 1025 of localhost. This server simply prints to standard output all email headers and the email body.


    72
    python -m smtpd -n -c DebuggingServer localhost:1025
    jemerick · 2009-02-05 16:50:44 3
  • If your web server is down, this command will periodically attempt to connect to it. If the output is blank, your server is not yet up. If you see HTML, your server is up. Obviously, you need to replace the Google URL with your web server URL... * 'watch' -- a command for re-executing a command and displaying the output * '-n 15' -- tells watch to redo the command every 15 seconds * 'curl' -- a handy utility for getting the source of a web page * '-s' -- tells curl to be silent about failing * '--connect-timeout 10' -- Try to connect for 10 seconds


    6
    watch -n 15 curl -s --connect-timeout 10 http://www.google.com/
    dltj · 2009-02-10 21:48:45 0
  • It is the best way i found to send a mail from the console in my centos server.


    5
    true | mailx -n -a MYTEXT.txt -r my@mail.com -s log -S smtp=mail.com -S smtp-auth-user=MYUSER -S smtp-auth-password=MYPASSWORD FRIEND@mail.com
    xmuda · 2013-03-12 16:37:30 0

  • 0
    (sleep 1;echo EHLO MAIL;sleep 1;echo "MAIL FROM: <a@foo.de>";sleep 1;echo "RCPT TO: <b@bar.eu>";sleep 1;echo DATA;sleep 1;echo Subject: test;sleep 1;echo;sleep 1;echo Message;sleep 1;echo .;sleep 1;)|openssl s_client -host b.de -port 25 -starttls smtp
    idella · 2017-05-06 17:53:38 0

What Others Think

Great !
CodSpirit · 461 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: