ASP MVC: Sending an E-mail

Posted by wh0emPah on Stack Overflow See other posts from Stack Overflow or by wh0emPah
Published on 2010-04-30T11:35:05Z Indexed on 2010/04/30 11:37 UTC
Read the original article Hit count: 429

Filed under:
|
|
|
|

Okay I'm kindoff new to the .NET platform. And currently i'm learning ASP MVC.

I want to send an e-mail from my program and i have the following code:

public void sendVerrificationEmail()
    {
        //create the mail message
        MailMessage mail = new MailMessage();

        //set the addresses
        mail.From = new MailAddress("[email protected]");
        mail.To.Add("[email protected]");

        //set the content
        mail.Subject = "This is an email";
        mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>";
        mail.IsBodyHtml = true;

        //send the message
        SmtpClient smtp = new SmtpClient("127.0.0.1");
        smtp.Send(mail);
    }

Now when i execute this code i'll get the following exception:

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25

Now i'm very very new to the IIS manager & stuff. so there is probably something wrong there.

Do i need to install a virtual smtp server or something?. Currently i have following settings (sorry not allowed to uplaod images yet =) ):

http://img153.imageshack.us/img153/695/capture2p.png

I've been looking for a few hours now but i can't seem to find a working solution.

Help would be appreciated!

Tyvm.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc