Sending email from gmail smtp server

You can do smtp server setting in either web.config or backend code.


            <network host="" userName="" password="yourpassword" port="587" enableSsl="true"/>


           SmtpClient smtp = new SmtpClient();
            var fromAddress = new MailAddress"", "Your Name");
            const string fromPassword = "yourpassword";            
smtp = new SmtpClient
                Host = "",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)

It is very handy if you don’t have a smtp server setup.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s