May 28, 2013 at 11:49 am
Im having problems sending mail from an on premise database server to an off premise exchange server with office 365. Has anyone gotten this to work. I can send mail from a script, can send mail using a gmail account, but i get "The mail could not be sent to the recipients because of the mail server failure." when i set it up to send through the online exchange server. I have even tried logging in with that account and sending mail online, so i know that the account works. Any help would be much appreciated.
Thanks
May 29, 2013 at 1:01 am
This was removed by the editor as SPAM
May 29, 2013 at 9:56 am
Using the same address and options such as SSL, i can send an email successfully using a VB script, ....
May 30, 2013 at 12:07 pm
You posted in the SQL 7,2000 Forum but I assume you're on a later version if you're using Database Mail. Please confirm.
If in fact you are using Database Mail I have set it up to use a Gmail and a Live/Hotmail account but never an Office 365 account. You might want to check their website to get details about how to use it as a mail relay from an external mail client like Outlook because the settings will be the same for setting up Database Mail.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
May 30, 2013 at 12:15 pm
opc.three (5/30/2013)
You posted in the SQL 7,2000 Forum but I assume you're on a later version if you're using Database Mail. Please confirm.If in fact you are using Database Mail I have set it up to use a Gmail and a Live/Hotmail account but never an Office 365 account. You might want to check their website to get details about how to use it as a mail relay from an external mail client like Outlook because the settings will be the same for setting up Database Mail.
Yup, your right, i posted it in the wrong place. Im trying to relay to an exchange server / email account hosted on Office 365
May 30, 2013 at 12:34 pm
we have office365, so i just setup and tested a dbmail using it;
here's the scripted results, which will probably help you a lot:
i was in a rush, and named both the account and the profile the same name, i hope that's not too confusing.
--#################################################################################################
-- BEGIN Mail Settings outlook.office365.com
--#################################################################################################
IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_profile WHERE name = 'outlook.office365.com')
BEGIN
--CREATE Profile [outlook.office365.com]
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'outlook.office365.com',
@description = 'outlook.office365.com';
END --IF EXISTS profile
IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_account WHERE name = 'outlook.office365.com')
BEGIN
--CREATE Account [outlook.office365.com]
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'outlook.office365.com',
@email_address = 'lowell@mycompanydomain.com',
@display_name = 'Lowell',
@replyto_address = '',
@description = 'outlook.office365.com',
@mailserver_name = 'outlook.office365.com',
@mailserver_type = 'SMTP',
@port = '587',
@username = 'lowell@mycompanydomain.com',
@password = 'NotTheRealPassword',
@use_default_credentials = 0 ,
@enable_ssl = 1 ;
END --IF EXISTS account
IF NOT EXISTS(SELECT *
FROM msdb.dbo.sysmail_profileaccount pa
INNER JOIN msdb.dbo.sysmail_profile p ON pa.profile_id = p.profile_id
INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id
WHERE p.name = 'outlook.office365.com'
AND a.name = 'outlook.office365.com')
BEGIN
-- Associate Account [outlook.office365.com] to Profile [outlook.office365.com]
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'outlook.office365.com',
@account_name = 'outlook.office365.com',
@sequence_number = 1 ;
END --IF EXISTS associate accounts to profiles
--#################################################################################################
-- Drop Settings For outlook.office365.com
--#################################################################################################
/*
IF EXISTS(SELECT *
FROM msdb.dbo.sysmail_profileaccount pa
INNER JOIN msdb.dbo.sysmail_profile p ON pa.profile_id = p.profile_id
INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id
WHERE p.name = 'outlook.office365.com'
AND a.name = 'outlook.office365.com')
BEGIN
EXECUTE msdb.dbo.sysmail_delete_profileaccount_sp @profile_name = 'outlook.office365.com',@account_name = 'outlook.office365.com'
END
IF EXISTS(SELECT * FROM msdb.dbo.sysmail_account WHERE name = 'outlook.office365.com')
BEGIN
EXECUTE msdb.dbo.sysmail_delete_account_sp @account_name = 'outlook.office365.com'
END
IF EXISTS(SELECT * FROM msdb.dbo.sysmail_profile WHERE name = 'outlook.office365.com')
BEGIN
EXECUTE msdb.dbo.sysmail_delete_profile_sp @profile_name = 'outlook.office365.com'
END
*/
Lowell
June 9, 2021 at 2:01 pm
I think "outlook.office365.com" cannot be used any more for SMTP because it has 2FA
April 18, 2022 at 5:53 pm
This was removed by the editor as SPAM
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply