Commands tagged smtp (7)

  • 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.


    76
    python -m smtpd -n -c DebuggingServer localhost:1025
    jemerick · 2009-02-05 16:50:44 87
  • Required curl version >=7.21; using ~/.netrc for authorization


    14
    curl -n --ssl-reqd --mail-from "<user@gmail.com>" --mail-rcpt "<user@server.tld>" --url smtps://smtp.gmail.com:465 -T file.txt
    mitry · 2010-10-03 15:44:53 20
  • 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) Show Sample Output


    7
    openssl s_client -starttls smtp -crlf -connect 127.0.0.1:25
    realist · 2009-08-19 08:37:24 5
  • I use this as an alias: alias authplain "printf '\!:1\0\!:1\0\!:2' | mmencode | tr -d '\n' | sed 's/^/AUTH PLAIN /'" then.. # authplain someuser@somedomain.com secretpassword AUTH PLAIN c29tZXVzZXJAc29tZWRvbWFpbi5jb20Ac29tZXVzZXJAc29tZWRvbWFpbi5jb20Ac2VjcmV0cGFzc3dvcmQ= # Show Sample Output


    4
    printf '\!:1\0\!:1\0\!:2' | mmencode | tr -d '\n' | sed 's/^/AUTH PLAIN /'
    vwal · 2009-08-04 05:04:50 4
  • Note, this works because smtp is running


    2
    mailx bar@foo.com -s "HTML Hello" -a "Content-Type: text/html" < body.htm
    ethanmiller · 2009-05-19 04:49:26 5
  • Lots of scripts show you how to use socat to send an email to an SMTP server; this command actually emulates an SMTP server! It assumes the client is only sending to one recipient, and it's not at all smart, but it'll capture the email into a log file and the client will stop retrying. I used this to diagnose what emails were being sent by cron and subsequently discarded, but you can use it for all sorts of things. Show Sample Output


    1
    socat TCP4-LISTEN:25,fork EXEC:'bash -c \"echo 220;sleep 1;echo 250;sleep 1;echo 250;sleep 1;echo 250;sleep 1;echo 354;sleep 1;echo 250; timeout 5 cat >> /tmp/socat.log\"'
    pfudd · 2014-11-26 21:14:05 15

  • 0
    authplain() { echo -n "AUTH PLAIN "; echo -n \\0$1\\0$2\\0 | base64; }
    danky · 2014-11-26 15:24:08 8

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


Check These Out

Watch active calls on an Asterisk PBX
Only the number of calls nothing else.

mirrors directory to a ftp server
http://lftp.yar.ru/

list files recursively by size

github push-ing behind draconian proxies!
If you are behind a restrictive proxy/firewall that blocks port 22 connections but allows SSL on 443 (like most do) then you can still push changes to your github repository. Your .ssh/config file should contain: Host * ForwardX11 no TCPKeepAlive yes ProtocolKeepAlives 30 ProxyCommand /usr/local/bin/proxytunnel -v -p -d %h:443 Host User git Hostname ssh.github.com ChallengeResponseAuthentication yes IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes Basically proxytunnel "tunnels" your ssh connection through port 443. You could also use corkscrew or some other tunneling program that is available in your distro's repository. PS: I generally use "github.com" as the SSH-HOST so that urls of the kind git@github.com:USER/REPO.git work transparently :) You

list files recursively by size

list files recursively by size

Create QR codes from a URL.
QR codes are those funny square 2d bar codes that everyone seems to be pointing their smart phones at. Try the following... $ qrurl http://xkcd.com Then open qr.*.png in your favorite image viewer. Point your the bar code reader on your smart phone at the code, and you'll shortly be reading xkcd on your phone. URLs are not the only thing that can be encoded by QR codes... short texts (to around 2K) can be encoded this way, although this function doesn't do any URL encoding, so unless you want to do that by hand it won't be useful for that.

host - DNS lookup utility
host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa. When no arguments or options are given, host prints a short summary of its command line arguments and options.

power off system in X minutes
Replace 60 with the number of minutes until you want the machine to shut down. Alternatively give an absolute time in the format hh:mm (shutdown -h 9:30) Or shutdown right away (shutdown -h now)

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.


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: