80

I am using SMTP to send emails by PHP. My client has a shared hosting. I created an email account there.

There is no information available about what will be the SMTP server for this account. I have tried: smtp.domainname.com But it's not able to connect.

How can I figure out my SMTP server host? any idea?

Dibya Sahoo
  • 839
  • 3
  • 9
  • 30
Krishna Kant Sharma
  • 1,567
  • 1
  • 12
  • 18

6 Answers6

183

this really is a question for Serverfault.

Windows:

  1. Open up a command prompt (CMD.exe)
  2. Type nslookup and hit enter
  3. Type set type=MX and hit enter
  4. Type the domain name and hit enter, for example: google.com
  5. The results will be a list of host names that are set up for SMTP

Linux:

  1. Open a command prompt
  2. Type dig domain.name MX and hit enter where domain.name is the domain you are trying to find out the smtp server for.

If you do not get any answers back from your dns server, there is a good chance that there isn't any SMTP Servers set up for that domain. If this is the case, do like other's have suggested and call the hosting companies tech support.

Elijah Lynn
  • 12,272
  • 10
  • 61
  • 91
Jordan S. Jones
  • 13,703
  • 5
  • 44
  • 49
  • 1
    This should indeed be the answer, but bear in mind, that this only gives you the 'external' SMTP server, i.e. the server which receives emails from other email servers. There are a lot of companies that use 'internal' mail servers to accept mails to be sent out. That server might not be the same, although it often is in small companies. – cimnine Apr 20 '17 at 13:48
  • This method should also work for an internal server if run on that same internal network (assuming internal DNS is setup correctly). – Jordan S. Jones May 23 '17 at 21:28
  • 1
    Actually the MX record tells you which server(s) the domain designates for _incoming_ email, but there is no specific guarantee that you can use the same server(s) for outbound. – tripleee Dec 21 '21 at 08:50
35

generally smtp servers name are smtp.yourdomain.com or mail.yourdomain.com open command prompt try to run following two commands

  1. >ping smtp.yourdomain.com
  2. >ping mail.yourdomain.com

you will most probably get response from any one from the above two commands.and that will be your smtp server

If this doesn't work open your cpanel --> go to your mailing accounts -- > click on configure mail account -- > there somewhere in the page you will get the information about your smtp server

it will be written like this way may be :

Incoming Server:    mail.yourdomain.com
IMAP Port: ---
POP3 Port: ---
Outgoing Server:    mail.yourdomain.com
SMTP Port: ---
RbG
  • 3,181
  • 3
  • 32
  • 43
19

You could send yourself an email an look in the email header (In Outlook: Open the mail, View->Options, there is 'Internet headers)

cimnine
  • 3,987
  • 4
  • 33
  • 49
  • 1
    Well i did that. i sent myself an email (to gmail account). And i read its header . But there is so much info out there. nothing like smtp.domainname.com or mail.domainname.com – Krishna Kant Sharma Sep 22 '09 at 16:34
  • 2
    Navigation path In my Outlook to see internet headers: _Open Message >> File >> Properties_. In the header look for text like "Recieved: from some.domain.org ... by ... our.domain.org" – matt wilkie Sep 01 '21 at 22:38
15

You can use the dig/host command to look up the MX records to see which mail server is handling mails for this domain.

On Linux you can do it as following for example:

$ host google.com
google.com has address 74.125.127.100
google.com has address 74.125.67.100
google.com has address 74.125.45.100
google.com mail is handled by 10 google.com.s9a2.psmtp.com.
google.com mail is handled by 10 smtp2.google.com.
google.com mail is handled by 10 google.com.s9a1.psmtp.com.
google.com mail is handled by 100 google.com.s9b2.psmtp.com.
google.com mail is handled by 10 smtp1.google.com.
google.com mail is handled by 100 google.com.s9b1.psmtp.com.

(as you can see, google has quite a lot of mail servers)

If you are working with windows, you might use nslookup (?) or try some web tool (e.g. that one) to display the same information.

Although that will only tell you the mail server for that domain. All other settings which are required can't be gathered that way. You might have to ask the provider.

tux21b
  • 90,183
  • 16
  • 117
  • 101
5

To automate the answer of @Jordan S. Jones at WIN/DOS command-line,

Put this in a batch file named: getmns.bat (get mail name server):

@echo off
if @%1==@ goto USAGE
echo set type=MX>mnscmd.txt
echo %1>>mnscmd.txt
echo exit>>mnscmd.txt
nslookup<mnscmd.txt>mnsresult.txt
type mnsresult.txt
del mnsresult.txt
goto END
:USAGE
echo usage:
echo %0 domainname.ext
:END
echo.

For example:

getmns google.com

output:

google.com      MX preference = 20, mail exchanger = alt1.aspmx.l.google.com
google.com      MX preference = 10, mail exchanger = aspmx.l.google.com
google.com      MX preference = 50, mail exchanger = alt4.aspmx.l.google.com
google.com      MX preference = 40, mail exchanger = alt3.aspmx.l.google.com
google.com      MX preference = 30, mail exchanger = alt2.aspmx.l.google.com

alt4.aspmx.l.google.com internet address = 74.125.25.27
alt3.aspmx.l.google.com internet address = 173.194.72.27
aspmx.l.google.com      internet address = 173.194.65.27
alt1.aspmx.l.google.com internet address = 74.125.200.27
alt2.aspmx.l.google.com internet address = 64.233.187.27

For example to pipe the result again into a file do:

getmns google.com > google.mns.txt

:-D

Codebeat
  • 6,501
  • 6
  • 57
  • 99
3

Quick example:

On Ubuntu, if you are interested, for instance, in Gmail then open the Terminal and type:

nslookup -q=mx gmail.com
Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130