Home How to know SmtpClient Host of my comany's email?
Reply: 2

How to know SmtpClient Host of my comany's email?

user2955394
1#
user2955394 Published in 2017-09-14 10:20:05Z

I tested sending email from gmail with the code below. It works well.

SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("mymail@gmail.com", "mypassword");
client.Send("mymail@gmail.com", "anothermail@hotmail.com", "Test Send Email", "Good Job");

But i want to change from gmail to my company's email. My email address at company like mymail@companyname.co.th. Then i change my code with the code below.It does not work.

SmtpClient client = new SmtpClient();
client.Host = "smtp.companyname.co.th";
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("mymail@companyname.co.th", "mypassword");
client.Send("mymail@companyname.com", "anothermail@hotmail.com", "Test Send Email", "Good Job");

I think it was wrong at this line.

client.Host = "smtp.companyname.co.th";

How to know SmtpClient Host of my comany's email?

Or what am I doing wrong?

Sorry for bad english skill.

ihopethisworks
2#
ihopethisworks Reply to 2017-09-14 14:36:14Z

This works for me, not sure about if it'll work for you.

1) Open CMD and type in:

nslookup

2) This will return DNS server name and IP. Next type:

set type=mx

3) Finally type in:

companyname.co.th

You should get your SMTP server name back. For the record, my company's SMTP server name is not the same as it's domain name.

jgrocha
3#
jgrocha Reply to 2017-09-14 10:23:52Z

The best guess is to do:

dig MX smtp.companyname.co.th

If you don't have dig installed, you can use an online tool, like: https://toolbox.googleapps.com/apps/dig/#MX/

Select only MX records.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.420835 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO