Troubleshooting Database Mail issues in SQL Server-
Use the Database Mail Configuration Wizard, and try to send a test mail to investigate the point of failure.
Right click database mail –View database mail log to see error or we can SELECT * FROM msdb.dbo.sysmail_event_log.
Check the sent_Status column in the sysmail_allitems table.
The four values are sent, unsent, retrying and failed-
1) If the status is sent and the recipients hasn’t received the email yet, that the Database Mail external program successfully delivered the e-mail message to the SMTP server but it failed to deliver the message to the final recipient. At this point, the SMTP needs to be checked and fixed. (Engage the Exchange or Mail server team).
2) If the status is unsent or retrying, it means that the Database Mail has not yet processed the e-mail message or is in the process of retrying after a failed attempt. This could be due to network conditions, volume of messages, SMTP server issues, etc. If the problem persists, use another profile or another mail host database.
3) If the status is failed, it means that the Database Mail was unable to deliver the message to the SMTP server. Check the sysmail_log table and the destination address. Also be sure that there are no Network or SMTP issues.
Send a test email outside SQL Server and check if the recipients are receiving mails. If they do not receive then the problem is outside SQL Server.
Engage Exchange or other mail server teams to identify why we are not able to send emails to Office outlook or other mail clients.
If the mail has successfully reached to recipients, then the problem is with in SQL Server mail configuration.
Verify the following-
- Verify if Service Broker is enabled (select is_broker_enabled from sys.databases where name=‘MSDB’ (0 – disabled, 1- enabled).
T-SQL – ALTER DATABASE MSDB SET ENABLE_BROKER
- Check if Database mail stored procedures are enabled (Surface Area Configuration >> “Surface Area Configuration for Features” >> Under MSSQLSERVER, expand Database Engine, and then click Database Mail. >> Ensure that Enable Database Mail stored procedures is selected, and then click Apply).
- Check if the user is part of DatabaseMailUserRole.
- Verify that the Database Mail executable is located in the correct directory – e.g. C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn and also verify, if ReadFromConfigurationFile is enabled.
- Verify that the service account for SQL Server has permission to run the executable, DatabaseMail90.exe, which requires network access to the SMTP servers specified in Database Mail accounts. Therefore, the service account for SQL Server must have permission to access the network, and the SMTP servers must allow connections from the computer that runs SQL Server.
- Verify the Anti-Virus scan properties, to see if ‘Mass-Mailing’ option is enabled.
This can also create hindrance while transmitting mails from SQL Server.
Hope this helps.