Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am created in my web application a send mail page that enable the user from sending email from the application without need to put his\her password.
the problem is when I run it it give me this exception :
550 5.7.1 Service unavailable, Client host [212.34.23.233] blocked using Spamhaus. To request removal from this list see http://www.spamhaus.org/lookup.lasso (AS16012612)


when the first time I used it , it sent the mail but I received it in the Spam e-mails .
how I can use the same way to send e-mails using this code or how I can edit it to make it in high performance .

What I have tried:

public void send_email()
  {
      SmtpMail oMail = new SmtpMail("TryIt");
          SmtpClient oSmtp = new SmtpClient();

          // Set sender email address, please change it to yours
          oMail.From = from.Text;


          // Set recipient email address, please change it to yours
          oMail.To = toddl.SelectedValue.ToString();

          // Set email subject
          oMail.Subject = subject_txt.Text;

          // Set email body
          oMail.TextBody = txtBody.Text;

        if(!string.IsNullOrWhiteSpace(ccddl1.SelectedValue.ToString()))
        {
            oMail.Cc.Add(new MailAddress(ccddl1.SelectedValue.ToString()));

        }

        if (!string.IsNullOrWhiteSpace(ccddl2.SelectedValue.ToString()))
        {
            oMail.Cc.Add(new MailAddress(ccddl2.SelectedValue.ToString()));

        }
        if (syllabus_attach.HasFile)
        {
            MemoryStream ms = new MemoryStream();
            syllabus_attach.PostedFile.InputStream.CopyTo(ms);
            var byts = ms.ToArray();
            ms.Dispose();
            string FileName = Path.GetFileName(syllabus_attach.PostedFile.FileName);
            oMail.AddAttachment( FileName,byts);
        }
       if (course_exam_attach.HasFile)
       {
           MemoryStream ms = new MemoryStream();
           course_exam_attach.PostedFile.InputStream.CopyTo(ms);
           var byts = ms.ToArray();
           ms.Dispose();
           string FileName = Path.GetFileName(course_exam_attach.PostedFile.FileName);
           oMail.AddAttachment(FileName, byts);
       }
       if (answer_key_attach.HasFile)
       {
           MemoryStream ms = new MemoryStream();
           answer_key_attach.PostedFile.InputStream.CopyTo(ms);
           var byts = ms.ToArray();
           ms.Dispose();
           string FileName = Path.GetFileName(answer_key_attach.PostedFile.FileName);
           oMail.AddAttachment(FileName, byts);
       }
       if (Exam_Mode_form.HasFile)
       {
           MemoryStream ms = new MemoryStream();
           Exam_Mode_form.PostedFile.InputStream.CopyTo(ms);
           var byts = ms.ToArray();
           ms.Dispose();
           string FileName = Path.GetFileName(Exam_Mode_form.PostedFile.FileName);
           oMail.AddAttachment(FileName, byts);
       }
          // Set SMTP server address to "".
       SmtpServer oServer = new SmtpServer("");


          // Do not set user authentication
          // Do not set SSL connection


              oSmtp.SendMail(oServer, oMail);
              string script = "alert(\"Request Sent Successfully!!\");";
                             ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);

      }
  }//end function
Posted
Updated 13-Apr-17 4:37am
v2
Comments
Afzaal Ahmad Zeeshan 13-Apr-17 10:19am    
Service unavailable means that you need to get in touch with the service itself, because they require some other header etc to provide services.
Rawan Mansourr 13-Apr-17 10:25am    
such as what?
Afzaal Ahmad Zeeshan 13-Apr-17 10:44am    
Such as, tell them that I am facing Service unavailable problem, what do I need to do? They would let you know, if their servers were down or if you need to send some private information before you can get authenticated for service.

Email providers are really strict in this because they have to be — otherwise they get hit by spammers.
Rawan Mansourr 13-Apr-17 11:05am    
do you have any solution to me?
Afzaal Ahmad Zeeshan 13-Apr-17 12:24pm    
Contacting the team, is the solution, sadly. :-)

1 solution

What that error means is the mail server that received your message thought it was spam based on a combination of several factors. The content, encoding, domain, signature, etc and for some reason flagged that as spam. When you continued to send a message Spamhaus blocked your ip or domain as belonging to a spammer. Like Afzaal said you need to contact Spamhaus or who ever own the main server you were sending the mail too

If you are planning on sending a large about of email such as newsletters, weekly site updates, etc I suggest you look into a service for that. Most ISPs will limit the amount of message that go out because they could get flagged as a spammer.
 
Share this answer
 
v2
Comments
Rawan Mansourr 13-Apr-17 11:05am    
I am sending from my own application why them block me as a spammer?
AnvilRanger 13-Apr-17 15:26pm    
That is something I cannot tell you. It has everything to do with the reasons I mentioned above. You need to contact Spanhaus they can tell you why.
Rawan Mansourr 13-Apr-17 15:36pm    
ok, thank you.

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