Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server sp_send_dbmail - How to send mail TO Gmail?

I am using sp_send_dbmail which is working perfectly except when I send to recipients using Gmail accounts. The database mail log give the following error:

Error,80,The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2015-05-29T13:22:39). Exception Message: Cannot send mails to mail server. (Unable to send to a recipient.))

All recipients not using Gmail receive the mail correctly.

When I use Outlook manually to send messages to this Gmail accounts it is working. The recipients receive the messages correctly. The SQL Server mail account is not using Gmail. I use Port 25 and SSL (I tried without SSL and it is not working either).

Here below the procedure call:

EXEC msdb.dbo.sp_send_dbmail 
    @recipients = '[email protected];[email protected]',
    @copy_recipients = '[email protected]',
    @profile_name = 'my_profile',
    @subject = 'mail subject',
    @body = 'some content',
    @body_format = 'Text';
like image 447
Marc Avatar asked Nov 10 '22 12:11

Marc


1 Answers

I tested the sp_send_dbmail proc in SSMS and it works fine for gmail. On the message panel, I got message 'Mail queued'. You may trouble shoot the queue using: msdb..sysmail_help_queue_sp @queue_type = 'Mail' ;

for me, it look like smtp mail relay issue. You should also test you DB mail profile setup.

like image 128
David J Avatar answered Nov 14 '22 22:11

David J