Click here to Skip to main content
15,906,296 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Whenever i am sending mail from gmail account its sending fine without any exception.
But when i tried it using some abc@daomin.com its failure.

MailMessage msg = new MailMessage();
            msg.From = new MailAddress(emailid);
            msg.To.Add(emailAddress);
            msg.Subject = "something";
            msg.Body = messageBody;
            SmtpClient sc = new SmtpClient("smtp.domainname.co.in");     
            
            sc.Credentials = new NetworkCredential(emailid, password);
            sc.EnableSsl = true;
            sc.Send(msg);


This code is not working .
I also tried by configuring web config.
XML
<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="customersupport@deals4sure.co.in">
        
        <network defaultCredentials="false" host="mail.deals4sure.co.in" enableSsl="true" userName="abcd@daomainname.co.in" password="*******" port="587"/>
      </smtp>
    </mailSettings>
  </system.net>


But also its not working
Please suggest something
Posted
Comments
bbirajdar 18-Dec-12 2:00am    
contact your email host

Try the following:

private void SendEmail(string from, string to, string subject, string message)
    {
        using (var email = new System.Net.Mail.MailMessage())
        {
            email.From = new System.Net.Mail.MailAddress(from);
            email.To.Add(to);

            email.Subject = subject;
            email.Body = message;

            var smtp = new System.Net.Mail.SmtpClient("IP ADDRESS HERE");
            smtp.Send(email);
        }
    }


Hope it helps, cheers.
 
Share this answer
 
Comments
avikGhosh87 18-Dec-12 2:29am    
same error occuring.
Eyakem 18-Dec-12 2:45am    
try these:
1. Identfiy the host, smtp.Host = "smtp.gmail.com";
2. Set the port number on your smtp client to 587, smtp.Port = 587;
3. gmail is secure so enable ssl, smtp.EnableSsl = true;

And last, please check if you have the login correct (case sensitive)
4. smtp.Credentials = new System.Net.NetworkCredential("youe_email@gmail.com", "your_password");
Usually most mail service providers only allow you to use their mail servers if you have an account with them.

So it begs the question whatever domain your using?....
abc@somedomain.com....

Do you have an account or membership with somedomain.com (whatever the name of the domain is)

and are you using the mailserver settings they gave you?
 
Share this answer
 
Comments
avikGhosh87 18-Dec-12 2:28am    
Yes zaf i am using mailserver settings.
Zaf Khan 18-Dec-12 2:36am    
In that case, the best solution is as aspnet_regiis said in his/her comment....

aspnet_regiis -i - 33 mins ago
contact your email host

To ascertain whats up with their mail server.
Zaf Khan 18-Dec-12 2:41am    
Additionally....
Taking myself as an example...
When I make any changes to my mailing components,
there is no facility for me to test it from my development server.
My service provider states i MUST upload it and use the script on the server.
When i say my mail service provider what i mean is my HOSTING provider.

So i don't know if thats worth looking into for yourself?
Are you sending it from your HOSTING providers webspace in your account?
And using your mailing account credentials they gave you or you set up?
If you answer Yes then its best you get on the phone it may save you LOTS of time.



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900