-
Notifications
You must be signed in to change notification settings - Fork 78
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
Direct access to sendgrid Mail object #45
Comments
@davegaeddert Thanks for your message. If I understand correctly, you want to add feature, to
@elbuo8 How do you think? |
We would have to add a section to handle it on |
Right, I guess what I'm wondering is if there's a more generic way to do it, so that you don't have to add lines like these for each property that just gets passed on to the sendgrid object:
The ones you have already seem handy, but it would be nice if there was a way to simply access the I'm not sure what the best way to do it would be though, since it looks like the email backend code doesn't get called until send? |
Only thing that comes to mind is patching the We could make a whitelist and copy properties to the mail object too. |
Maybe a whitelist of properties that can all be copied is as good as anything. The other thing that came to mind for me, which might not be a good pattern, would be to pass a function that could get called. Haven't tried any of this but something like: mail = EmailMultiAlternatives(
subject="Your Subject",
body="This is a simple text email body.",
from_email="Yamil Asusta <[email protected]>",
to=["[email protected]"],
headers={"Reply-To": "[email protected]"}
)
def sendgrid_mail_func(mail):
mail.tracking_settings = 'anything you need'
# etc.
mail.modify_sendgrid_mail_func = sendgrid_mail_func Then in your backend if hasattr(email, 'modify_sendgrid_mail_func'):
email.modify_sendgrid_mail_func(mail) |
+1 |
@andriisoldatenko Sounds fine to me. Is that something that you guys are open to tackling relatively soon? |
Is there any update on this being tackled? Specifically the handling of mail.tracking_settings? |
Personally I don't need this anymore (trying to close some old issues...). Feel free to reopen if somebody actually cares about this still. Thanks! |
I'm wanting to change some additional settings on the sendgrid Mail object before it's sent (specifically click tracking - https://github.com/sendgrid/sendgrid-python/blob/master/sendgrid/helpers/mail/mail.py#L23).
I was wondering if there is or should be a more generic way to access the underlying object that comes out of _build_sg_email? Suggestions for how to accomplish that (happy to help do it)?
Thanks for your work on this!
The text was updated successfully, but these errors were encountered: