Archive for December, 2011
How to see open/inactive connections on your computer/server? (BSD, Linux, OS X)
Posted by Roger Brown in Uncategorized on December 15, 2011
To see what network/internet connections are open to your computer OR on your server, run this command from a Terminal:
netstat -anpt
And if you have root or sudo access, then run netstat -anptu if you also want to see the users listed.
Example: to see a list of all open connections from a single username IP address –
netstat -anptu | grep USERNAME
OR from a single IP address –
netstat -anptu | grep IP
Thanks to my coworker for showing me these additional switches and the searching for IP address example on netstat! I already knew about `netstat -an` and `netstat -rn`.
How to speak IMAP? (for testing/debugging problems)
Posted by Roger Brown in Internet on December 13, 2011
Sometimes you’re not sure where the problem lies with checking email via IMAP in your favorite program such as Thunderbird or Apple Mail or Outlook.
So to see whether it’s a problem with the software you need to speak IMAP directly to your server.
Open a Terminal or Command prompt and run these commands. **Replace the parts with []‘s with your info AND leave out the brackets!**
+++++++++
telnet [IMAP SERVER NAME] 143
a login [EMAIL@DOMAIN] [PASSWORD]
a list “” “*”
a select inbox
a logout
+++++++++
here’s an example:
~~~~~~~~~~~~~~~~~
~/www/ $ telnet mail.sciencefun.net 143
Trying 67.20.121.71…
Connected to sciencefun.net (67.20.121.71).
Escape character is ‘^]’.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
a login test@sciencefun.net dr0wss@p!
a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS QUOTA] Logged in
a list “” “*”
* LIST (\HasChildren) “.” “INBOX”
* LIST (\HasNoChildren) “.” “INBOX.Sent”
* LIST (\HasNoChildren) “.” “INBOX.Junk”
* LIST (\HasNoChildren) “.” “INBOX.Drafts”
* LIST (\HasNoChildren) “.” “INBOX.Trash”
a OK List completed.
a select INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft $Junk NonJunk $label1 $label4 $label2 $NotJunk)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $Junk NonJunk $label1 $label4 $label2 $NotJunk \*)] Flags permitted.
* 289 EXISTS
* 0 RECENT
* OK [UNSEEN 170] First unseen.
* OK [UIDVALIDITY 1278944964] UIDs valid
* OK [UIDNEXT 305] Predicted next UID
* OK [HIGHESTMODSEQ 283] Highest
a OK [READ-WRITE] Select completed.
a logout
* BYE Logging out
a OK Logout completed.
Connection closed by foreign host.
~~~~~~~~~~~~~~~~~
P.S. Want to test downloading an email? Let’s say I want to look at the 10th message in the Inbox. (the 1st one would be the oldest email).
Unlike POP where you can retrieve a whole email with a single command. In IMAP you have to retrieve it with 2 commands.
A. Retrieve the Headers (though in a special imap format that runs them all together on one line)
a FETCH 10 full
Here’s the output:
* 10 FETCH (FLAGS (\Seen) INTERNALDATE "05-May-2011 10:32:38 -0600" RFC822.SIZE 43832 ENVELOPE ("Mon, 02 May 2011 19:41:03 -0400" "PhysOrg Newsletter Monday, May 2" (("Newsletter Physorg.com" NIL "not-for-reply" "physorg.com")) (("Newsletter Physorg.com" NIL "not-for-reply" "physorg.com")) (("Newsletter Physorg.com" NIL "not-for-reply" "physorg.com")) (("rbrownscience" NIL "rbrown" "sciencefun.net")) NIL NIL NIL "0fc49dc2e12256796d7da00e8d861cf8.NewsletterPhysorgcom@physorg.com") BODY ("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 42019 806))
a OK Fetch completed.B. Retrieve the body of the email:
a FETCH 10 body[text]
Thanks to http://webhostingneeds.com/Testing_IMAP for teaching me the FETCH commands!
How to speak SMTP?
Posted by Roger Brown in computers, Internet, Uncategorized on December 10, 2011
Sometimes when you’re having trouble sending email and none of your troubleshooting has worked so far, you need to connect to your outgoing email server and speak the language to it that your email program speaks when it sends an email:
To test outgoing SMTP email, you first need to “base64 encode” these two things:
#1 – your full email address
#2 – your email password
SMTP authentication uses base64 encoding.
Here’s one tool to do that at:
http://www.opinionatedgeek.com/dotnet/tools/base64encode/
Go ahead and do that for both the full email address and the email password and save the output.
Then open up a terminal or a command prompt on your computer.
+++Below is what you will type from it.
Anywhere it has words in all CAPS you will replace that with your domain name for example.
And you will press the Enter key after each line
NOTE also — the lines or words below that are inside of brackets []‘s are just instructions; you do not type those. But you type everything else. +++++++++++
telnet mail.DOMAIN.COM 25
ehlo DOMAIN.COM
auth login
[paste in your email address encoded in base64. Below is an example]
ZW1pbHlAY29tbMNuaXR5Y2h1cmZoZ3JvdXAuY29t
[paste in your password encoded in base64. Below is an example]
YmBzZAJhbCd=
mail from: YOURADDRESS@DOMAIN.COM
rcpt to: OTHERADDRESS@DOMAIN2.COM
data
From: YOURADDRESS@DOMAIN.COM
To: OTHERADDRESS@DOMAIN2.COM
Subject: test of SMTP
this is a test message
. [type a single dot and then press enter]
quit
+++ end of telnet commands +++
P.S. some outgoing servers will have you use a different port number such as 587 or 26. Above we used port 25.