SQL Mail problem "The mail could not be sent to the recipients because of the mail server failure"

I have setup DB mail on our SQL server 2012. There are 2 profiles and the 'Send test email' works for both.

I have set one of these profiles on a job but I am getting this error: -
Date            14/05/2018 09:38:30
Log            Database Mail (Database Mail Log)

Log ID            295
Process ID            44936
Mail Item ID      101
Last Modified      14/05/2018 09:38:30
Last Modified By      sa

Message
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2018-05-14T09:38:30). Exception Message: Cannot send mails to mail server. (A recipient must be specified.).
)

Can anyone help?
HKFueyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
If Send Test mail works and not working from the job, then it has something to do with Authentication of Database Mail profile.
Configure it to make use of Basic or Anonymous Authentication to get it work..

If Send Test mail is not working, then we need to check for several other scenarios as mentioned below..
http://sivasql.blogspot.com/2012/11/sql-mail-mail-could-not-be-sent-to.html
0
Eugene ZCommented:
please check your code

and make sure "A recipient is specified"

as per the posted error
Exception Message: Cannot send mails to mail server. (A recipient must be specified.).

something  like

EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'testProfile',
   @recipients = 'John@Doe.com',
    @subject = 'Test Message',
    @body = 'test'
 

more

sp_send_dbmail (Transact-SQL)

https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-send-dbmail-transact-sql?view=sql-server-2017
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HKFueyAuthor Commented:
OK thanks guys, will do some testing when I get a spare 5 mins!

Strangely enough one profile (sending to me) works, the other (sending to a group address) does not.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
>> one profile (sending to me) works, the other (sending to a group address) does not.

There might be few cases like sending to a group address can be disabled at AD level for certain users, check with your Windows/Active directory team once..
0
ajohnson30Network ManagerCommented:
FYI: exchange distribution groups wont be able to receive emails from non-exchange accounts unless they have the option set in delivery management to receive emails from "senders inside AND outside my organization"
0
HKFueyAuthor Commented:
I will change the group setting on 365 and re test
0
HKFueyAuthor Commented:
Hi Eugene,

If I add a job step and put in your script it works as I want: -
EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'SQL-Monitor',
   @recipients = 'sql_monitor@mydomain.co.uk', --This is the Office 365 distribution group
    @subject = 'Test Message',
    @body = 'test'

This is not difficult so I may copy this to the 'Failure' event on jobs I need to monitor.
0
Eugene ZCommented:
very good!
0
HKFueyAuthor Commented:
Thanks all
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.