Error in email code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bluenose
    New Member
    • Apr 2012
    • 56

    Error in email code

    Hello

    When I debug my SMTP code, which is not sending a form, I get the following:

    Troubleshooting Exceptions: System.Net.Mail .SmtpException

    - The exception that is thrown when the SmtpClient is not able to send a Send

    System.Net.Mail .SmtpException was caught
    HResult=-2146233088
    Message=Error in processing. The server response was: Greylisted, please try again in 180 seconds
    Source=System
    StackTrace:
    at System.Net.Mail .RecipientComma nd.CheckRespons e(SmtpStatusCod e statusCode, String response)
    at System.Net.Mail .SmtpTransport. SendMail(MailAd dress sender, MailAddressColl ection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecip ientException& exception)
    at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
    at Contact.SendEma il_Click(Object sender, EventArgs e) in C:\Users\Steve\ Documents\Visua l Studio 2013\VHS-DVD\Contact.asp x.vb:line 140
    InnerException:

    Line 140 is this:

    Code:
    Smtpserver.Send(myMessage)
    But that doesn't tell me much, or how to correct it.

    This is my SMTP code (stripped):

    Code:
     Protected Sub SendEmail_Click(sender As Object, e As System.EventArgs) Handles SendEmail.Click
    
    Dim myMessage As New MailMessage
    Dim Smtpserver As New SmtpClient
    
    Dim user_name As String = Request.Form("user_name")
    Dim user_email As String = Request.Form("user_email")
    Dim user_subject As String = Request.Form("user_subject")
    Dim user_message As String = Request.Form("user_message")
    
    myMessage.From = New MailAddress(user_email) 'User email
    myMessage.To.Add(New MailAddress("info@mysite.com")) 'Webmaster
    myMessage.CC.Add(New MailAddress("info1@mysite.com")) 'Webmaster's assistant
                
    myMessage.Subject = user_subject
    myMessage.Body = user_message
    
    Smtpserver.Host = ("IP_Add")
    Smtpserver.Port = 25
    
    Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@mysite.com", "pwd")
    Smtpserver.Send(myMessage)
    Where could the error be, please? This is the URL:



    Thank you.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Did you read the error message?
    Especially this part:
    "The server response was: Greylisted, please try again in 180 seconds"

    So, wait for 180 seconds, and ty again!

    Greylisting is a way to avoid SPAM. A 'normal' spammer only tries 1 time to send mail, and does not care about failed delivery's. A 'normal' mailserver will retry sending the message several times. It will only stop sending after a configured time (a couple of days)

    Comment

    • Bluenose
      New Member
      • Apr 2012
      • 56

      #3
      Thanks, Luuk

      I didn't know that.

      Sorry for the delay in replying - I was disconnected.

      Regards

      Comment

      • johnedword
        New Member
        • Mar 2018
        • 2

        #4
        Sometimes your SMTP server may return a particular error message. The problem is that it will generally be very cryptic, like "550 Requested action not taken: mailbox unavailable" or "421 Try again later". What does these numbers mean?

        First of all: not any reply code is an error. Sometimes it's just a response containing a detail about the server or an answer to a command. Secondly: any code consist of three digits, and each conveys a particular information. The first one defines whether the server has accepted the command, fulfilled an action, run into a temporary issue, encountered an error etc; the second and the third one refine the description further, stating if there's been a syntactic problem, or a connection trouble etc.

        Unfortunately, different servers sometimes use these codes in a different way, making the whole thing even more complicated... Anyhow, the most critical series of error messages is the 5xx one, and especially the ones from 550 to 559. In particular, you will probably get a lot of 550 SMTP error codes – that is, a problem that concerns the recipient's email address.

        Finally, remember that it's much easier to deal with these error codes if you choose to rely on a professional SMTP server that will help you solve any issue.

        Best Advice:
        Similar to email marketing, sending largely depends on target audience. The service SMS helps for a marketer to send his message to multiple consumers with a personal approach and with 100% rate of positive reading of the text.
        Last edited by zmbd; Oct 14 '18, 04:07 PM. Reason: [Rabbit; Removed link][Z: Removed reference to commercial service doesn't add to the conversation]

        Comment

        • Luuk
          Recognized Expert Top Contributor
          • Mar 2012
          • 1043

          #5
          The truth is any 5xx error will, and should,make it clear that an SMTP message is NOT accepted by the server!

          A 4xx error can, (and maybe even should if needed!), be re-tried!

          Comment

          Working...