Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Code to stop Unable to Relay message for email

Hi
I have the code below, which works fine for sending internal email. Works on a PC.
But for external email, I get the message:
Mailbox unavailable. The server response was: 5.71. unable to relay
I've searched online, but the solutions seem to involve making changes on the exchange server. Is there a way I can add settings through code to fix this issue?


Dim smtp As New SmtpClient("mymailservername")
Dim mailClient As New MailMessage()

  With mailClient
            .From = New MailAddress(TM_FROM)
            .To.Add(stAgent_Email)
            .Subject = stSubject
            .Body = stBody
         End With

         'send the message
         smtp.Send(mailClient)

Open in new window

0
jdhackett
Asked:
jdhackett
  • 4
  • 3
1 Solution
 
Tony JLead Technical ArchitectCommented:
Afraid you need to change the permissions on the Exchange server.

This is by design to stop viruses, rogue programs etc doing exactly this - using your server as an open relay and spamming.
0
 
jdhackettAuthor Commented:
Ok, can you tell me how to change the permissions on the Exchange server so? Its Exchange 2010, I can't find the "SMTP Virtual Server" that the online help refers to.
0
 
Tony JLead Technical ArchitectCommented:
Here you go:

http://msexchangeteam.com/archive/2006/12/28/432013.aspx

I generally utilise a new connector.

By the way - I realise it's for 2007 but it's valid for 2010 too.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
jdhackettAuthor Commented:
Followed those instructions, added the IP of my PC, used Option 1. Still getting the same problem though. Any other ideas?
0
 
CodeCruiserCommented:
0
 
Tony JLead Technical ArchitectCommented:
Hmm it should work - I've used it myself several times.

But i've usually granted the anonymous permission too.

Indeed, there's actually an updated article the suggests it's the preferred method:

http://technet.microsoft.com/en-us/library/bb232021.aspx

CodeCruiser - your method would bypass the Exchange server, therefore bypassing things like message tracking.
0
 
jdhackettAuthor Commented:
Working now! I was still trying to figure it out, when I tried again and it worked. I think there must be a 10 minute delay between setting it up on the mail server and it actually working?

Either way, all good to go now, thank you.
0
 
Tony JLead Technical ArchitectCommented:
Ah good - I've never noticed a delay quite that long before but good to know you got it running :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now