Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sendgrid Python reply_to email

I have errors when I use reply_to, here is what I've tried...

This works but without reply_to :

mail = Mail(
    from_email = from_email,
    to_emails = to_email,
    subject = subject,
    html_content = content)
response = sg.client.mail.send.post(request_body=mail.get())

And I've tried this :

mail = Mail(
    reply_to = reply,
    from_email = from_email,
    to_emails = to_email,
    subject = subject,
    html_content = content)
response = sg.client.mail.send.post(request_body=mail.get())

This thows :

TypeError: init() got an unexpected keyword argument 'reply_to'

I have also tried to add this after Mail() :

mail.from_EmailMessage(reply_to=ReplyTo(Email(email=ANS_EMAIL,name='Mr X')))

Which throws :

TypeError: object of type 'Email' has no len()

And :

mail.reply_to(ReplyTo(email=ANS_EMAIL,name='Mr X'))

Which throws :

TypeError: 'NoneType' object is not callable

Any help please ?

like image 724
toioioi Avatar asked Oct 24 '25 05:10

toioioi


1 Answers

As your error states reply_to is not accepted in init(). Try setting reply_to after you have created the Mail object.

Example Below:

mail.reply_to = "[email protected]"

or 

message.reply_to = ReplyTo('[email protected]', 'Reply Here')

More details on how to customize sendgrid email object - Link

like image 132
Subhrajyoti Das Avatar answered Oct 26 '25 18:10

Subhrajyoti Das



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!