Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure single-tenant application support, using the Graph API #6728

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(microsoft): send mail using graph api if tenant is set
  • Loading branch information
moxvallix committed Mar 22, 2023
commit 5953c6026ac67ca4e76a218dec5d3eed9cb0c162
12 changes: 11 additions & 1 deletion app/mailers/conversation_reply_mailer_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ def prepare_mail(cc_bcc_enabled)

def ms_smtp_settings
return unless @inbox.email? && @channel.imap_enabled && @inbox.channel.provider == 'microsoft'
return ms_graph_settings if ENV.fetch('AZURE_TENANT_ID', false)

smtp_settings = {
address: 'smtp.office365.com',
address: 'smtp-mail.outlook.com',
port: 587,
user_name: @channel.imap_login,
password: @channel.provider_config['access_token'],
Expand All @@ -40,6 +41,15 @@ def ms_smtp_settings
@options[:delivery_method_options] = smtp_settings
end

def ms_graph_settings
graph_settings = {
token: @channel.provider_config['access_token']
}

@options[:delivery_method] = :microsoft_graph
@options[:delivery_method_options] = graph_settings
end

def set_delivery_method
return unless @inbox.inbox_type == 'Email' && @channel.smtp_enabled

Expand Down