Mail Sending Problem in asp.net Server Rejected Sender Address, Error Code 551

hi.,
am getting error while sending a mail ..
i have contact us form, i need to send a mail from any domain to a speciifed domain
like from address  may be yahoo, gmail or anything but the To address will be a single domail.

here is the code which i have used.. plz can any one help me..
public bool SendMail(Panel body, string subject, string from)
    {
        try
        {
            MailMessage message = new MailMessage();
            message.To = "mail@mydomain.com";
            message.From = from;     // any domian.. 
            message.Subject = subject;
            message.BodyFormat = MailFormat.Html;
            message.Body = "<html><head></head><body width='550px'><div align='left' width='550px' style='font-family: Arial; font-size:x-small'>" + PanelToHtml(body) + "<br/></div></body></html>";
 
            string Username = "mail@mydomain.com";
            string Password = "mypassword";
 
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //none, cdoBasic, NTLM
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", Username);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", Password);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2); // cdoNTLM, value 2. The current process security context is used to authenticate with the service.
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", false);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60);
 
            string SmptServer = "mail.domain.com";
            System.Web.Mail.SmtpMail.SmtpServer = SmptServer;
            System.Web.Mail.SmtpMail.Send(message);
            return true;
        }
        catch(Exception ex)
        {
            throw ex;
        }
    }
 
    public string PanelToHtml(Panel PanelMail)
    {
        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter(sb);
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        PanelMail.RenderControl(hw);
        return sb.ToString();
    }

Open in new window

LVL 2
Rajeshk_cgmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Melih SARICAOwnerCommented:
U dont ave rely permission on server..

Ask ur mail admin to give u rely permission..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.