Database Mail

  • 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

  • This was removed by the editor as SPAM

  • Using the same address and options such as SSL, i can send an email successfully using a VB script, ....

  • 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

  • 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

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I think "outlook.office365.com" cannot be used any more for SMTP because it has 2FA

  • 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