Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a problem in sending emails...

i have a application i am using system.net.mail namespace
when i run my application in visual studio in my system its working perfectly..
but when i uploaded my site to server it creates problem emails are not sending when i use my site from there.. its very strange problem whole site working perfectly except this problem...


using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Mail;
using System.Net.Mail;


public class EmailManagment
{
    SmtpClient client = new SmtpClient();
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("emailus@eventsitsolution.com", "mypassword");

    public void sendemail(string sendto, string subject, string body)
    {
        try
        {
            client.Host = "smtpout.secureserver.net";
            client.Port = 80;
            client.UseDefaultCredentials = false;
            client.Credentials = credentials;
            client.EnableSsl = false;
            // convert strings to mail address
            MailAddress to = new MailAddress(sendto);
            MailAddress from = new MailAddress("emailus@eventsitsolution.com");
            //
            msg.Subject = subject;
            msg.Body = body;
            msg.To.Add(to);
            msg.From = from;
            msg.IsBodyHtml = true;
     
            client.Send(msg);
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
    }
}


when i want to send email i just call send email method.
Posted
Updated 28-May-11 4:32am
v2
Comments
Bryian Tan 28-May-11 10:18am    
hi,

Did you get any error message? Maybe you can show us some codes.
se.nishant 28-May-11 10:33am    
if any error available it should occur on my system also
#realJSOP 29-May-11 7:46am    
Not necessarily. YOUR system is on an ip address that the email server finds acceptable. The remote machine may not be.

1 solution

It's probably because your email server doesn't allow relays.
 
Share this answer
 
Comments
se.nishant 28-May-11 10:29am    
any solutions for this problem?
#realJSOP 29-May-11 7:46am    
Use a different email server.
se.nishant 28-May-11 10:35am    
and tell me how its run on my system..
se.nishant 28-May-11 10:48am    
hello friend i checked my hosting plan i have 250 relays per day and i used only 11 today..
now i think this is not the problem...
#realJSOP 29-May-11 7:50am    
You're allowed to relay a limited number of times? I've never heard of an ISP providing limited relays before. Have you checked with your web host to see if they can help?

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