views:

519

answers:

2

Has anyone ever tried sending emails using 1&1 smtp host? I tried the following?

SmtpClient mailClient = new SmtpClient("smtp.1and1.com", 587);
mailClient.Credentials = new NetworkCredential("[email protected]", "password");

But it always gives me a security exemption error...

I tried it using my local host and it works fine.. I tried using gmail's smtp and it worked fine as well.. It says that I need to authenticate in order to use the smtp server, I did that by looking at the code above... Here's the exact error:

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

A: 

also just ensure that your reverse (PTR) maps back to you... otherwise alot of SMTP servers will reject you.

kSiR
+1  A: 

You need to authenticate to send SMTP mail (Point 2a from their FAQ)

Alex K.
problem is how can I authenticate ?
EquinoX
I understand authenticate just means to provide username and password in the smtp and I did that from the code above
EquinoX
googling specifically for '1and1 system.net.mail' throws up lots of people with the same problem and this SO post from a few months ago http://stackoverflow.com/questions/1915032/1and1-windows-hosting-with-asp-net "1and1 do not allow access to system.net.mail"
Alex K.
Try auth.smtp.1and1.com instead of smtp.1and1.com
stevejalim