Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1564
  • Last Modified:

Error while sending an email form my website with SmtpClient.

I'm developing a website with ASP.NET 2005 and C#. I tried to send emails from my website
using the code I put in code section.
it gives me the follwing error:
"Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server"
If I change the mairTo to "info@sharplabelcutter.com"  which is my website, it'll work fine. But this way I can only send emails to my own website.!
Please help me how to solve my problem.
string mailFrom =  "myemail@yahoo.com";
 string mailTo =      "freind_email@yahoo.com";;
        
        System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage("contact@sharplabelcutter.com", mailTo);
        
        email.Subject = "subject";
        email.IsBodyHtml = true;
 
        email.Body = " body of the email";
 
        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
        System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("contact@sharplabelcutter.com", "my_password", "webmail.sharplabelcutter.com");
        //mailClient.Host = "";
        mailClient.Port = 25;
        mailClient.UseDefaultCredentials = false;
        mailClient.Credentials = basicAuthenticationInfo;
 
        try
        {
            mailClient.Send(email);
        }
        catch (Exception ex)
        {
           return ex.string();
        }

Open in new window

0
Elham_Seif
Asked:
Elham_Seif
3 Solutions
 
Éric MoreauSenior .Net ConsultantCommented:
you will surely find your solution from http://www.systemnetmail.com/
0
 
Faheem ShaikhCommented:
Have a look here for some causes and resolutions of this:
http://www.mailenable.com/kb/Content/Article.asp?ID=me020390
 
0
 
Ramone_HamiltonCommented:
Are you using your own smtp server?  If so check to make sure that it is capable of sending e-mails outside of your domain.  I believe that most webmails such as hotmail, yahoo or gmail won't accept your e-mails unless they are coming from a legit exchange or smtp server connected to a static ip address.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Elham_SeifAuthor Commented:
Hi
I got confused reading those long sites about emails.
Would you please read my code and tell me what's wrong with the code?
What can I use instead, to make it run correctly.
The one that can correct my code will get the points.
Thanks in advance.
0
 
Ramone_HamiltonCommented:
You haven't set the address of the smtpclient you are sending from.  Try this:

System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp1.myhost.com");
0
 
Elham_SeifAuthor Commented:
Hi Ramone_Hamilton
my host is www.sharpLabelCutter.com.
what should I write instead of "smtp1.myhost.com" in the code you said?
0
 
Ramone_HamiltonCommented:
Are you running your own smtp service or is your web page being hosted by another company?
0
 
Elham_SeifAuthor Commented:
Hi Ramone_Hamilton
My website is hosted by another company.
How can I run my won smtp service? And what's the diffrence?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now