Last active
December 17, 2015 01:59
-
-
Save orlando/5532781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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