Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to export my emails from my email account on a linux email server to Gmail. So I was wondering how to get its incoming and outgoing hostnames and ports and get to know if it supports POP3 or IMAP? For example, by some commands that I can run on the server's bash shell?

Thanks and regards!

share|improve this question
Please clarify this question. From your question, it sounds like you want to push email from a linux box to gmail. In your response to Nathan's answer, it sounds like you want mail to go from gmail to your linux box when it is received by google. – Alex Jun 16 '10 at 3:13
Sorry for the confusion. I want to push email from a linux email server to gmail, so I need to know the hostname and port of the email server and whether it support POP3 or IMAP. – Tim Jun 16 '10 at 3:48
up vote 1 down vote accepted

What information do you have about the mail server? Are you able to log into it? This should provide you with the hostname, or you can use the hostname command to get it when you are logged in. If that name doesn't correspond to the "real" hostname, then you can always look it up if you know the IP address of the server, by doing a domain name lookup on it (here is an example looking up

$ nslookup

The netstat command provided above will tell you what ports the linux server is listening on, but the -n tells it not to resolve IPs and Port names, and instead to display the raw numbers. If you leave off the -n you'll see hostnames and port numbers, or you can just look for the ports that POP and IMAP use, 110 and 143 respectively. Of course it should be noted that those ports are not secure by default, and anything transmitted to them over the internet will be in the clear unless the email client is configured to do a TLS upgrade.

Hope some of that helps.

share|improve this answer

I am not 100% sure what you are asking, but to see what is listening, you can use either netstat, or nmap.

netstat would be local:

netstat -pan | grep LISTEN | less

nmap can be local or remote:

share|improve this answer
Thanks. I would like to know hostname and port of the email server, so that I can export my emails from the email server to my Gmail account. The methods you mentioned seem not provide such information. – Tim Jun 16 '10 at 3:47

Your Answer


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.