i use the following code to send email :
public static bool SendEmail(string To, string ToName, string From, string FromName, string Subject, string Bod
Assuming the SMTP server (smtp.datagts.net) is running fine, some items to check:
UseDefaultCredentials=true
, but on the next line your are providing credentialsmedium trust
. IF so, you cannot use any port for SMTP other than Port 25.Update:
To try and get to the error. In your LOCAL (development) machine, add this to your web.config:
<system.web>
...
<securityPolicy>
<trustLevel name="Medium" />
</securityPolicy>
...
ASP.Net on your local machine runs in FULL TRUST
. The above setting makes the current web site/application you are working on run in medium trust
. You can remove/comment as necessary. The point of this exercise is to try and match what your web host settings are (it's obviously different if things work in your local machine then dies when published). It would be nice to just obtain the info from your web host..but until then....
Then try both Port 587 and 25.
medium trust
)GMAIL is the same story. You cannot use Port 587 if your web host settings for ASP.Net is medium trust
. I have been through this many times - it will "work" in my local machine, but as soon as I enable medium trust
in my local development machine, it will fail.
You should ask your web host what their settings are for ASP.Net - if its some "custom" setting you can ask for a copy and use that in your dev box as well.