tags:

views:

80

answers:

6

Run time exception is: The transport failed to connect to the server. Please give me any of your suggestions. As i am working on my own pc so i do not have any mail server so i put the name of my internet broadband provider (SmtpMail.SmtpServer = "smtp.virginmedia.com";) Is it the right way

A: 

Make sure that the server accepts your connection.

matt b
A: 

The first step is to read the error message.

At a guess, I would say that this error is caused because the web application is unable to connect to a particular server. Then we go look up the documentation for SmptMail class to see what could cause that.

The first thing we see is that the System.Web.Mail API is obsolete and that you should use System.Net.Mail.SmtpClient instead.

Anon.
A: 

It could be because

  • your smtp server name does not resolve
  • your smtp server ip or port is incorrect
  • your smtp server requires authentication
  • your smtp server requires ssl
cdonner
A: 

You will need to check with your provider to see if they support SMTP and to get the correct server address. You might consider installing an SMTP server on your machine.

You might also want to try using an SMTP test tool. This is a quick and easy way to test different settings without having to deal with any other possible issues in your own code. There are a few good ones out there. I've used one before but I don't remember which one, sorry.

Brian
A: 

I'd recommend that you try using System.Net.Mail instead of SmtpMail, but that may not solve your connection problem.

Before you get too wrapped up in diagnosing connection problems in your project, make sure you can send a message using a standard email client like Outlook or Pine. Then copy your settings from the mail client into your code or into your web.config file to set the SMTP server connection.

Paul Keister
A: 

If you are using a hosting service they likely have permissions fairly strict on the server.

In a lower trust mode on the server, all SMTP connections must be setup using web.config. If you try to pass a address inline in your code you violate trust conditions.

http://stackoverflow.com/questions/587117/smtpclient-half-working-half-not

Präriewolf