Among the most common items in a web site is the implementation of email. There are many ways of implementing email from a web site. You can use a multitude of technologies to accomplish this. This article is not to discuss different methods but to look at one method which is asp.net. You could just set the settings (server, login, password, etc) in code and use the standard SMTP code that so many sites put together, however; I have found this to be cumbersome when you are deploying the site to production. Furthermore; after you publish to production any further testing will mingle the production emails among the testing emails. So what can you do to make this an easier transition? If you are familiar with VS 2012 transformation then you can see where I am going. If not then be prepared to learn something new today.
- Start by creating a VS2012 project.
2. Once you have done this then your solution explorer should look like figure 2.
3. Click on ‘Show All files’ (figure 2)
4. Open your web.config file and enter the following;
Note: This will create the email and save it in the D:\ drive. The nice thing about this is that you can then use Outlook, or Thunderbird to actually open the file to test your output (email) without it actually sending anything but a file email.
5. Open up Web.Release.config and add the following;
<network host="mail.MAILSERVER.com" port="25" userName="EMAILADDRESS" password="XXXXXX"/>
Note: At Arvixe this is typically your server name
6. When you compile or deploy, change your compiler instance (figure 3). This will transform the web.config to the new method.