Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2005
    Posts
    833
    Rep Power
    12

    Error: Mailbox unavailable. The server response was 5.7.1 Unable to relay for (email)


    Hi. I am trying to programmatically send an email to end users based on certain bahaviours (such as forgotton password, etc). But, I am getting the error:

    Mailbox unavailable. The server response was: 5.7.1 Unable to relay for (email address).

    I have done some reading about this and it seems that most people are able to fix this error by doing the following:

    1) Right click on Default SMTP Virtual Server and select properties
    2) Select the access tab
    3) Click the Relay button
    4) Click the Add button
    5) Type in your ip address

    I have tried this but am still getting the same error. .
    does anybody have any idea what else i might be doing wrong??

    thanks tons
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2005
    Posts
    833
    Rep Power
    12

    Post for what it is worth...


    for what it is worth, here is the code:

    Code:
     'contstruct the message to be sent to the customer
                                Dim MailServer As String = "Server"
                                Dim ToEmail As String = _newPass.Text
                                Dim ToName As String = first + " " + last
                                Dim FromEmail As String = "customersupport@emailaddress.com"
                                Dim FromName As String = "Customer Support"
                                Dim Subject As String = "Do Not Reply: Your Forgotten Password"
                                Dim Body As String = "Message Body"
                                Dim o_Client As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient(MailServer)
                                Dim o_FromAddress As System.Net.Mail.MailAddress = New System.Net.Mail.MailAddress(FromEmail, FromName)
                                Dim o_ToAddress As System.Net.Mail.MailAddress = New System.Net.Mail.MailAddress(ToEmail, ToName)
                                Dim o_Message As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage(o_FromAddress, o_ToAddress)
                                o_Message.Subject = Subject
                                o_Message.Body = Body
    
                                Try
                                    o_Client.Send(o_Message)
                                
                                Catch exc As Exception
                                
                                End Try
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Posts
    2
    Rep Power
    0

    Cool Use myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis


    I had been looking for this too and just found it; solved it by specifying a DeliveryMethod of PickupDirectoryFromIis. For this to work you need to have SMTP Server running.

    For example:

    Dim myMailClient As New System.Net.Mail.SmtpClient(AppSettings("SMTPHost"))

    myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

    myMailClient.Send(strFromEmail, strTo, strSubject, strBody)
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Posts
    2
    Rep Power
    0

    Cool No need for special relay settings


    Followup to the last post -- there is no need for special relay settings if you use the above method. Which is great because if you have a site where people can email themselves or others (like a "Tell a Friend" feature) I'm not sure how to do it other than 1) allowing anyone to relay or 2) entering all the possible target domains / IP addresses in the access settings!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    1
    Rep Power
    0
    Originally Posted by dsergovic
    myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
    This is exactly what I was looking for. Thanks!
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2006
    Location
    Pennsylvania, USA
    Posts
    90
    Rep Power
    9
    I don't know if those will solve the original problem or not, but just in case not, the error your getting in regards to relaying is to prevent unauthorized use of an email server.

    Generally it occurs when you have a mail server (e.g. mailserver.com) from one domain, and the addresses are from other domains. Either the From or the To address need to belong to the domain (myname@mailserver.com or yourname@mailserver.com). If neither of the addresses belong to a domain that the mail server 'owns', then you are relaying, which is a spam technique and is generally not allowed nowadays.

    Unless you need to receive mail back, you can have the From address be a made-up address within the mail server's domain since you don't need to check it.

    Hope that may clear up where the message may be coming from.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    1
    Rep Power
    0
    Cool. My application was having the same issues with sending email and I just added the SmtpDeliveryMethod you mentioned and it works.

    Thanks!

    Originally Posted by dsergovic
    I had been looking for this too and just found it; solved it by specifying a DeliveryMethod of PickupDirectoryFromIis. For this to work you need to have SMTP Server running.

    For example:

    Dim myMailClient As New System.Net.Mail.SmtpClient(AppSettings("SMTPHost"))

    myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

    myMailClient.Send(strFromEmail, strTo, strSubject, strBody)
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Posts
    1
    Rep Power
    0

    Workin!


    myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

    Workin!
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    1
    Rep Power
    0
    myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

    Working 100%! Thank you very much!
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    1
    Rep Power
    0

    Question


    I tried this too and it actually worked! So I put the code into my whole program, everywhere I'm emailing and when I go to test it, it's not working now. Here's my code:

    Code:
     Dim msg As String = "Another test.  Thank You!"
                   msg += "<br>athon@divrafts.com"
            Dim emp_email As String
            emp_email = "athon@divrafts.com"
    Dim message As New System.Net.Mail.MailMessage("itdept@divrafts.com", emp_email, "test", msg)
            message.IsBodyHtml = True
    
            Dim emailClient As New SmtpClient("mail1")
            emailClient.Host = "mail1"
            'Dim SMTPUserInfo As New System.Net.NetworkCredential("mrequester", "schedule", "DN")
    
            ''emailClient.UseDefaultCredentials = False
            ''emailClient.Credentials = New Net.NetworkCredential("aton", "fco")
            emailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
    
            Try
                emailClient.Send(message)
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    any ideas as to what could be wrong or what I need to do? I'm stumped because it was working before and now it's not. I dno't think I really changed anything except added this code a few times on each page. Thanks in advance for any help!
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    1
    Rep Power
    0

    Spam mails i'm receiving


    I used this
    Use myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

    now the mails are receving in spam

    what i have to do now?
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    1
    Rep Power
    0

    how about c#


    Originally Posted by bajisankar
    I used this
    Use myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

    now the mails are receving in spam

    what i have to do now?
    can anyone tel me how
    can i resolve the same
    ie Mailbox unavailable. The server response was: 5.7.1
    in c#
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    1
    Rep Power
    0
    Originally Posted by marutiskutre
    can anyone tel me how
    can i resolve the same
    ie Mailbox unavailable. The server response was: 5.7.1
    in c#

    Try this,

    <mailSettings>

    <smtp from="someone@domain.com">

    <network host="mailserver.domain.com" password="mypassword" userName="myuser"/>

    </smtp>

    </mailSettings>

    This will allow you to send the email to anyone outside the network.

    Thanks and Regards
    Ashok Bhawar
    E-Commerce Solution Specialist
    ashokbhawar at gmail
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2009
    Posts
    1
    Rep Power
    0
    Hey even I was facing the same problem from a long time, and had mail server on a different machine.
    This line worked for me.

    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

    where smtp is the smtp client.
    hope it works for others as well!

    Comments on this post

    • Direhit disagrees : Don't bump a nearly year old thread for no reason.
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0
    Hi all,

    Can anyone explain that why we want to use this code

    myMailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis


    Thanks & Regards,
    B. Rajasekar
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo