You are here: Home / Documentation / Installation / Server Part Installation / Activate Database Emails

Activate Database Emails

Some additional functions of eWay-CRM are based on the server database and they are even able to use functions of the SQL Server. The most frequent example is the sending of notification emails, activated by various triggers. The technological solution for sending emails is different from standard notifying emails which eWay-CRM sends. If you want to use any of additional functions it is necessary to adjust the SQL server correctly. The server needs to be able to send emails.

Note: Sending emails from SQL is only supported by versions of SQL Server and Management studio which are higher than Express.

Process

The process has two steps. Adjusting the email profile for sending mail and then it is necessary to modify the procedure which provides the sending of emails.

Create Email Profile and Set Permissions

After the connection to the server via Management Studio select Manage in Object Explorer and right-click Database Mail. Select Configure Database Mail from the context menu.

Then the Configuration Wizard will appear. When the introduction window is displayed, click Next to choose settings. Select Manage Database Mail accounts and profiles from the menu and continue by clicking Next. In the next step, select Create a new profile and again click Next.

In the next window, define the Profile name for the new profile (1). This name will be needed again in the database settings. Then click Add account (2) and then click Creation of new SMTP account.

In the newly opened window, specify the email of the sender (for example [email protected]_domain.com), the name or IP of SMTP server (adjust the number of a port and safety connection according to settings of the server) and if the server needs verifying, enter the data in the Basic authentication section in the bottom part of the window.

Confirm settings by OK and click Finish in the next window.

Permissions to Send Emails From SQL Server

Now, it is necessary to assign permissions for the sending of emails to the user to enable him the database login. Usually, it is the name of the user: euser, but if you want to check the correctness of this statement, take a look in the web.config file, which is in the web service folder (can usually be found in C:\Inetpub\wwwroot\eWay\Web.config). The name of the user is listed in the section <appSettings>, the USER ID is in the ConnectionString parameter. It is necessary to set permissions to this user for the sending emails on the SQL server. It is called test in this case.

The assignment of permissions has two steps. First, in Management studio in Object explorer, select Security and then Logins, where you have to choose the user for eWay-CRM from the list of users (in our case it is euser), right-click the user and select Properties from the menu. In the dialog window select the User mapping section, on the right side choose the msdb database, which you have to mark and at the bottom of window define the user permissions for DatabaseMailUserRole. Accept by OK.

The second step that must be done, is to enable access to the user (to enable him the database login – in our case euser) to mail profile. Go to the Management section in Object explorer and select Configure Database Mail by right-clicking it. Select Manage profile security from the list and continue by clicking Next. In the followinf step, click Private profiles and choose euser user from the User name menu. eWay profile should be marked. Continue with the Next button.

Adjust Database Procedure Settings for Sending of Emails

The final step is to adjust the procedure in the eWay database which provides the sending of emails. In management studio open the database: eWay > Programmability > Stored Procedures, in this section, find the procedure dbo.eWaySP_SendMail, right-click it and select Modify.

In the editing window the definition of the procedure will appear. Delete the commentary /* and */ marked in blue in the picture. Enter the profile name which you defined in the creation of the profile - the parameter @profile_name. (In our case we enter eWay). When you have finished editing, press F5 to save changes. This is complete adjustment the emails database functionality.