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

sendgrid_actionmailer_settings => options #58

Open
joshm1204 opened this issue Jan 7, 2020 · 5 comments
Open

sendgrid_actionmailer_settings => options #58

joshm1204 opened this issue Jan 7, 2020 · 5 comments

Comments

@joshm1204
Copy link

What are the options you can set for sendgrid_actionmailer_settings? e.g. can you set the 'domain'?


config.action_mailer.sendgrid_actionmailer_settings = {
    api_key: '',
    raise_delivery_errors: true
  }
@tyrauber
Copy link
Collaborator

@joshm1204, those appear to be the only two options available. This gem utilizes the send-grid ruby gem which makes use of the Sendgrid v3 Mail Api. I see no reference to setting a 'domain' there. But the sender domain is referenced in the 'from' and 'reply-to'? Is that what you are looking for?

@ur5us
Copy link

ur5us commented Dec 17, 2020

@tyrauber I assume @joshm1204 means setting the host which is possible with sendgrid-ruby and useful for testing, especially with apps recreating the Sendgrid API but otherwise acting like a mail catcher of some sorts.

@tyrauber
Copy link
Collaborator

@ur5us Thanks for the clarification. sendgrid-actionmailer currently only passes the api_key to sendgrid-ruby, but as you suggest there are additional attributes that can be set through sendgrid-ruby API initialization, specifically api_key, host, request_headers, version, and impersonate_subuser.

It would take a little bit of refactoring, but this gem could pass a settings hash to SendGrid::Api.new instead of just an api_key. The only major caveat is it would also need to take into account merging in instance set settings - mail_settings passed to mail that overwrite the default initializer settings.

What purpose or functionality would these additional attributes provide?

@ur5us
Copy link

ur5us commented Dec 22, 2020

@tyrauber There are multiple purposes I think but one specific is this: https://github.com/TimKaechele/PostDoc Currently, it’s not possible to use PostDoc as a custom host can’t be configured.

@tyrauber
Copy link
Collaborator

@ur5us Give the branch feature/sendgrid_api_settings a try.

gem 'sendgrid-actionmailer', github: 'eddiezane/sendgrid-actionmailer', branch: 'feature/sendgrid_api_settings'

It should enable you to globally pass api_key and host ( or the other SendGridApi client settings) to sendgrid_actionmailer_settings:

config.action_mailer.sendgrid_actionmailer_settings = {
 api_key: ENV['SENDGRID_API_KEY'],
 host: ENV['SENDGRID_HOST']
}

or the mail instance through delivery-method-options:

mail(to: '[email protected]',
 subject: 'email subject',
 body: 'email body',
 delivery_method_options: {
   api_key: 'SENDGRID_API_KEY',
   host: 'SENDGRID_HOST'
 }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants