Skip to content

Instantly share code, notes, and snippets.

@orlando
Last active December 17, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orlando/5532781 to your computer and use it in GitHub Desktop.
Save orlando/5532781 to your computer and use it in GitHub Desktop.
var message = new MailMessage();
message.To.Add("user@example.com");
message.To.Add("user2@example.com");
message.From = new MailAddress("test@example.com");
message.Subject = "Test";
message.Body = "Test";
var client = new SmtpClient("localhost", 25);
client.Send(message);
// also you need to add this to your web.config, obviously you need to add your smtp information here,
// ask your sysadmin for it.
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="no-reply@xxxxxx.com">
<network host="xxx.xxx.xxx.xxx" port="25" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
// if you can't send emails, then maybe is your local smtp doesnt work.. try with your gmail account
<system.net>
<mailSettings>
<smtp from="yourMailId@gmail.com ">
<network host="smtp.gmail.com" defaultCredentials="false"
port="587" userName ="yourmail@gmail.com" password="yourpassword" />
</smtp>
</mailSettings>
</system.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment