We help IT Professionals succeed at work.

5.7.1 Unable to relay

I have a Win 2003 Server.  I'd like to have my ASPX script send an email but not sure what settings I need to make on the server to make this happen.

When I run my script now I get the following error:

System.Net.Mail.SmtpFailed

RecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for me@myemailaddress.com at System.Net.Mail.SmtpTransport.SendMail


I have the following in my web.config file:

    <system.net>
        <mailSettings>
            <smtp>
                <network host="my.server.com"/>
            </smtp>
        </mailSettings>
    </system.net>

Is there something I need to do in the IIS Administrator in order for mail to go out?
Comment
Watch Question

Author

Commented:
Just incase you need it, here's my code...
Imports System.Net
Imports System.Net.Mail
Imports Microsoft.VisualBasic

...

            ' Create the MailMessage instance
            Dim mail As New MailMessage()

            ' FROM:
            mail.From = New MailAddress("me@myeamiladdress.com", "Mr. Me")

            ' TO:
            mail.To.Add("you@youraddress.com")

            ' SUBJECT & BODY
            mail.Subject = "My Subject"
            mail.Body = "Hello There, how are you?"
            mail.IsBodyHtml = False

            ' Create the SmtpClient object
            Dim smtp As New SmtpClient

            ' Send the MailMessage (will use the Web.config settings)
            smtp.Send(mail)

Open in new window

Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
Here's a whole web site dedicated to it: http://www.systemnetmail.com/

Author

Commented:
I believe so?  Have a look at the attached screenshot.  Maybe I need to do something else? Screenshot
I found my answer.  It looks like I just needed to add the following line to my code....

smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis

Thanks for your help.

Author

Commented:
Needed to add a line of code.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.