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

Add support for SMTP configuration for api key based auth #208

Open
Shikhar-Nahar opened this issue Feb 5, 2024 · 2 comments
Open

Add support for SMTP configuration for api key based auth #208

Shikhar-Nahar opened this issue Feb 5, 2024 · 2 comments

Comments

@Shikhar-Nahar
Copy link

Currently the SMTP configuration is only possible via username andpassword authentication. However, using external service providers such as SendGrid requires login via apikey and setting the from mail to a specific id as whitelisted on the SMTP service provider.
Related to Issue#79
Currently it is not possible to configure SMTP to user SendGrid with the params allowed in
This blog gives the example for sending email using smtplib for SendGrid.

Which requires specifying the login user as 'apikey' while setting the from email to a specified whitelisted email.
The minimal required change for this feature would be to allow setting 'from' email in the email header as per user specified value.

smtp:
  email_mode: sendgrid  
  from_email: whitelisted-user@example.com
  login_user: apikey
  server: smtp.sendgrid.net
  port: 465
  password : <apikey>

and code in sender.py in herald to support above.

Tested with a workaround code like below which works

def _send_email_to_user_smtp():
    message.replace_header('From',from_email)
    try:
        with smtplib.SMTP_SSL(server, port) as smtp_server:
            smtp_server.ehlo()
            smtp_server.login(login_user, password)
            smtp_server.sendmail(from_email, message.get("To"), message.as_string())
@tguisep
Copy link
Contributor

tguisep commented Feb 13, 2024

As workaround, finally I implemented an other solution - for invitation mainly - using a custom SMTP script and Optscale API to avoid code change.

@maxb-hystax
Copy link
Member

Are you going to publish it in your fork? Maybe we'll be able to incorporate it into the code soon.

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