cannot relay through smtp server in

dave_e_work used Ask the Experts™
him hope you can help, I have the following code:

Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("", "mypassword")
SmtpServer.Host = ""
SmtpServer.EnableSsl = False
mail.From = New MailAddress("", "Mr Smith", System.Text.Encoding.UTF8)
mail.Subject = "Website Contact Entry"
mail.IsBodyHtml = True
mail.Body = "my message"

The thing is, it works perfect when I run it from my localhost, as soon as it is live, it doesn't work, doesn't show any errors and looks like it has sent it.

Can you point me in the right direction?

thanks in advance
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

You should make some changes to your smtp server to accept and relay messages from your web server. Most smtp servers by default do not accept messages from other machines. If someone else administers your smtp server, then ask them to "allow relaying" for the IP address of your web server.
When you use SMTP authentication, relaying should not be a problem. Your credentials might have not been passed properly. If server supports SSL for SMTP which is port 567 trying using
SmtpServer.EnableSsl =True,

Or see below configuration. It should work .

MailMessage message = new MailMessage(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text);
SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text);
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(txtSMTPUser.Text, txtSMTPPass.Text);
emailClient.UseDefaultCredentials = false;
emailClient.Credentials = SMTPUserInfo;
litStatus.Text = "Message Sent";
You need to confirm the relay server
SmtpServer.Host = ""

Issue is in the address.
Gary DavisDir Internet Svcs

Is there anything in the Event Viewer to help pinpoint the failure?
In IIS you have to add the ip-adres of server to enable relaying from that adress
I managed to figure this out, we were sending to and from the same email address, hence the authentication issues. Thanks for your help though.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial