Asp net send email through 1and1 smtp


ASP.NET is a popular language used for developing web . One common requirement in web applications is the ability to send emails. In this article, we will explore how to send emails through the 1and1 SMTP server using ASP.NET.

Setting up SMTP

Before we can send emails through the 1and1 SMTP server, we need to configure the SMTP in our ASP.NET application. This can be done in the web.config file of the application. Here is an of how to configure the SMTP settings:


In the above example, we specify the host, port, username, , and enable SSL for the 1and1 SMTP server. Make sure to replace “your_username” and “your_password” with your actual credentials.

Sending an Email

Now that we have configured the SMTP settings, we can proceed to send an email using ASP.NET. Here is an example of how to send an email:

using .Net.Mail;

public void SendEmail()
    MailMessage mail = new MailMessage();
    SmtpClient smtpClient = new SmtpClient();

    mail.From = new MailAddress("");
    mail.Subject = "Hello from ASP.NET";
    mail.Body = "This is a test email sent through ASP.NET";


In the above example, we create a new instance of the MailMessage class and set the sender, recipient, subject, and body of the email. We then create an instance of the SmtpClient class and call the Send to send the email.


Sending emails through the 1and1 SMTP server using ASP.NET is a straightforward process. By the SMTP settings in the web.config file and using the MailMessage and SmtpClient , we can easily send emails from our ASP.NET applications.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents