Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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.
<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 17-Dec-12 19:41pm
Comments
aspnet_regiis -i at 18-Dec-12 2:00am
   
contact your email host
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
avikGhosh87 at 18-Dec-12 2:29am
   
same error occuring.
Eyakem at 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");
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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?
  Permalink  
Comments
avikGhosh87 at 18-Dec-12 2:28am
   
Yes zaf i am using mailserver settings.
Zaf Khan at 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 at 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)

  Print Answers RSS
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100