开发者

Error while trying to send an email in asp.net

开发者 https://www.devze.com 2023-04-09 20:39 出处:网络
I was trying to impliment an email option in my program.. The follwing exception was thrown +$exception {\"The server rejected one or more recipient addresses. The server response

I was trying to impliment an email option in my program.. The follwing exception was thrown

+$exception {"The server rejected one or more recipient addresses. The server response 
was: 550 5.7.1 <"mail-id">... Relaying denied. IP name lookup failed [172.25.9.23]\r\n"}    
System.Exception {System.Web.HttpException}

This is what i have done......

     MailMessage objEmail = new MailMessage();
        objEmail.To     = txtTo.Text;
        objEmail.From   = txtFrom.Text;
        objEmail.Cc     = txtCC.Text;
        objEmail.Subject = txtSubject.Text;
        objEmail.Body   = txtBody.Text; ;
        objEmail.Priority = MailPriority.High;

        WebMsgBox.Show("test");
        SmtpMail.SmtpServer = "someserver.com";
        MailAttachment attach = new MailAttachment(@"D:\email.txt");
        objEmail.Attachments.Add(attach);

        try
        {          
            SmtpMail.Send(objEmail);
            WebMsgBox.Show("Your Email has been sent sucessfully - Thank you");
        }
        catch (Exception exc)
        {
      开发者_如何转开发      WebMsgBox.Show("Send failure: " + exc.ToString());

        }


Perhaps check that the server you are using to send with (smtp) has the sender machine IP whitelisted. I don't actually know how this is done but your infrastructure folks could help. Seems as though the smtp server has been secured somewhat.


When we try to send mail, there are lots of configuration settings have to be ok including some background things. (mailserver, antivirus, firewalls,routers, anti spyware etc…). Have you checked your SMTP server (services) is enabled or not ?

I am not sure 100% that below steps solve your problem, but you can check your SMTP server configurations by it :

  1. In the Control Panel >> Administrative Tools >> Internet Information Services.
  2. Open the node for your computer, right-click the Default SMTP Virtual Server node and choose Properties.
  3. In the Access tab, click Connection.
  4. Select Only the list below, click Add and add the IP 127.0.0.1. This restricts connections to just the local computer, i.e., localhost. Close the Connection dialog box.
  5. Click Relay and repeat Step 4 to allow only localhost to relay through this server.

For IIS7, you can do it by :

  1. Open IIS and select the node for your computer, double click on "SMTP Email" option at right side panel.
  2. You can set SMTP server and port details there.

In your firewall or router (or both), close incoming port 25. This is an important security measure that will prevent spammers from finding your SMTP server and using it to relay spam.

Hope this will solve your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消