ASP.NET - The remote name could not be resolved: 'smtp.ezsoft-sol.in'

Asked By aileni giri on 27-Mar-12 02:30 AM
i got an error while sending email
 the error is as  follows 
   The remotre server could not be resolved: 'smtp.ezsoft-sol.in'


the  following is the code.


string @from = ConfigurationManager.AppSettings["email"].ToString();
    string pwd = ConfigurationManager.AppSettings["pwd"].ToString();
    //SmtpClient smtpClient = new SmtpClient();
    MailMessage message = new MailMessage();
    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
    string m1 = pocmail;
    mail.To.Add(m1);
     
      mail.From = new MailAddress(@from, @from, System.Text.Encoding.UTF8);
      mail.Subject = "JobOrder Details";
      mail.SubjectEncoding = System.Text.Encoding.UTF8;
      mail.Body = "Recruitment Drive:"
      mail.BodyEncoding = System.Text.Encoding.UTF8;
      mail.IsBodyHtml = true;
      mail.Priority = MailPriority.High;
      SmtpClient client = new SmtpClient();
      client.Host = "smtp.ezsoft-sol.in";
      client.Port = 25;
     
     // client.UseDefaultCredentials = true;
     // client.Credentials = new System.Net.NetworkCredential(@from, pwd);
     //client.EnableSsl = true;
      client.Send(mail);


please  anybody help me.
dipa ahuja replied to aileni giri on 27-Mar-12 02:41 AM
Step 1 : Add this in Web.config
    
<system.net>
<mailSettings>
<smtp>
<network host="smtp.gmail.com"
  port="587"
  userName=""
  password=""
</smtp>
</mailSettings>
</system.net>
  
Step 2 : Mail Sending Code
 
using System.Net.Mail;
using System.Net;
 
protected void btnSent_Click(object sender, EventArgs e)
{
  string toEmailAddress = "xx@gmail.com";
  string GmailId = "abc@gmail.com";
  string bodyMsg = "helo its testing mail";
  string subject = "testing mail";
  MailMessage mail = new MailMessage();
  mail.To.Add(toEmailAddress);
 
  mail.From = new MailAddress(GmailId);
  mail.Subject = subject;
  mail.Body = bodyMsg;
  mail.IsBodyHtml = true;
 
    SmtpClient smtp = new SmtpClient();
  smtp.EnableSsl = true;
  smtp.Send(mail);
}
 
 
Somesh Yadav replied to aileni giri on 27-Mar-12 02:45 AM
In my opinion, this error message is quite self-explanatory: You cannot create a connection to the SMTP server you have specified.
 
There is probably nothing wrong with your code as it is.
 
You need to check why you can't access the SMTP server.
 
For starters, try pinging smtp.nimanaqipour.com from the machine your application is running on.

or

If it is having issues resolving the server name, then that is likely a DNS issue on the server. CS simply goes to the connect to the given hostname, and the system will automatically try to resolve the hostname into an IP using the DNS servers the server is configured to use.
 
Take not of the email server setting in CS, then log into the server, open a command prompt, and type "nslookup youremailserver.com". if it can't resolve it, then you might want to check the DNS settings for the domain, or the DNS servers your server is set up to use.
 

BTW: Before that, just check it's not the firewall creating the issue. Port being used is open and permissions given.
aileni giri replied to dipa ahuja on 27-Mar-12 03:10 AM
i did it ,but i am getting same error.
          Thanks.
kalpana aparnathi replied to aileni giri on 27-Mar-12 03:11 PM
hi,

This Error  means the computer asked for the IP-address of 'smtp.ezsoft-sol.in' at your configurated DNS server and this returned it couldn't find an IP-address for 'smtp.ezsoft-sol.in'.

please check for this:

Is 'smtp.ezsoft-sol.in' a valid address?

Is there a DNS server configured at the computer and has this DNS server a valid DNS entry for 'smtp.ezsoft-sol.in'?

Regards,

aileni giri replied to kalpana aparnathi on 28-Mar-12 06:23 AM
thanks alot ya.