Send email using mvc5 asp net and rackspace


ASP.NET is a popular programming language used for building web applications. In this article, we will explore how to send emails using MVC5 ASP.NET and Rackspace as the email service provider.

Setting up Rackspace Email Account

Before we can start sending emails, we need to set up a Rackspace email account. these steps to create an account:

// Rackspace email 
 smtpServer = "";
int smtpPort = 587;
string username = "";
string password = "your-password";

Configuring SMTP Settings

Next, we need to configure the SMTP settings in our ASP.NET application. Open the web.config file and add the following code inside the section:


Creating Email

Now, let's create an EmailController that will handle the email sending . Add a new controller to your MVC5 project and name it EmailController. Inside the controller, add the following code:

using .Net.Mail;

public  EmailController : Controller
    public ActionResult SendEmail()
         mail = new MailMessage();
        mail.From = new MailAddress("");
        mail.Subject = "Hello from ASP.NET";
        mail.Body = "This is a test email sent using ASP.NET MVC5 and Rackspace.";

         smtpClient = new SmtpClient();

        return View();

Sending Email

To send an email, we can simply call the SendEmail action method from our view or another controller. For example, let's create a button in our view that triggers the email sending:

@using (Html.BeginForm("SendEmail", "Email", FormMethod.Post))

When the user clicks the “Send Email” button, the SendEmail action method will be called, and the email will be sent using the SMTP settings.


In this article, we have learned how to send emails using MVC5 ASP.NET and Rackspace as the email service provider. By following the steps outlined above, you can easily integrate email functionality into your ASP.NET web application.

Rate this post

Leave a Reply

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

Table of Contents