Ibrahim Fakih
Ibrahim Fakih

Reputation: 61

Django - Sending email with sendgrid templates - problem with a from address

I am using Sendgrid Dynamic Transactional Templates to send emails from my django project. The code can be seen below.

sg = SendGridAPIClient(djangoSettings.SENDGRID_KEY)
    message = Mail(
            from_email = some@email,
            to_emails=some@email,
    )
    message.dynamic_template_data = {...
            }

    message.template_id = '....'

    response = sg.send(message)

The email sends fine, but I need to use a from_email to send. I don't want to use an email they can reply to. I want some generic email associated with my sendgrid account, lets say mydomain.com. How can I go about solving that?

Upvotes: 0

Views: 763

Answers (1)

Kareem
Kareem

Reputation: 609

If you have authorized the domain in your Sendgrid account you can add any address you want so long as it's part of the authorized domain.

To do this go to, https://app.sendgrid.com/settings/sender_auth, press Authenticate your domain and follow the steps to add your domain. This includes configuring your DNS, DKIM and SPF. For more details on adding a domain visit here

Now in your code, you could add [email protected], or any variation of that, as the from address so long as you authenticated yourdomain.com.

Upvotes: 0

Related Questions