How to configure SMTP mail setting

You can use the SMTP server to send and receive email. The default configuration is to use the default mail server for your domain. You can change this setting to another SMTP server if you want. There are many different email servers to choose from. One of the more popular email servers is Gmail. Gmail has a very easy-to-use interface, but it doesn't allow you to use a third-party mail client. Other popular email servers are Yahoo, Hotmail, and Outlook. These email servers allow you to use third-party mail clients, but they are more difficult to set up. You can set up an email account on Gmail using the Google Mail app. It's very easy to do, and all you need is a Google account. First, open the Google Mail app and click on the Settings icon in the upper right corner. Then, click on Accounts and Import. Select Add Account and choose Other. Type in your name, email address, and password for your email account. You can also add a nickname for your account if you want. Click Next and you're done!

How to configure SMTP mail setting

To enable email, configure an SMTP email service as follows: Set up an SMTP email sending service (if you don't yet have an SMTP service with credentials) Any SMTP email service can be used, you just need the following information: Server Name , Port , SMTP Username , and SMTP Password . 


There are a number of things that you have to consider:

  1. Dont fetch the smpt parameters from database inside the function. Pass the parameters to the fun
  2. ction. This will helps if you want to send many emails repeatedly and you don't have to connect to database each time.
  3. Don't suppress the exception. Log it or throw the exception so that outer module can handle it.
  4. As said earlier by c45207, store the full SMPT host address in the database. 
  5. The code only sends mail to single person. Instead use IList _pToMailId and loop it as follows:

                foreach (var to in _pToMailId)
                    message .To.Add(to);

    You can repead this for CC and BCC respectively.