1&1 web hosting and smtp configuration

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("<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e283868f8b8ca29287908f8b8391cf969781918d8ccc818d8f">[email protected]</a>", "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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

Method 2

My client has a new hosting from 1and1.com, and the thing that worked for me was to remove the port number and it working. 1and1 provided me a reference link http://help.1and1.com/hosting-c37630/scripts-and-programming-languages-c85099/aspnet-c39624/send-an-e-mail-using-aspnet-a604246.html

My code:

SmtpClient objSmtp = new SmtpClient("smtp.1and1.com");
objSmtp.EnableSsl = true;
objSmtp.Credentials = new   
System.Net.NetworkCredential("<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="016c60686d41646c60686d2f6e7366">[email protected]</a>", "PWD");

Method 3

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x