Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email django from using EmailMultiAlternatives

I'm trying to send a mail using Django with EmailMultiAlternatives. It works well but in "from" says "info"

Is it posible to say my name for example? How can I do this?

Here is my code:

subject, from_email, to = 'Afiliations', '[email protected]', '[email protected]'
text_content = 'Afiliation is working.'
t = loader.get_template('emails/afiliados.html')
c = Context({ 'order': order_obj })
html_content = t.render(c)
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
like image 396
Disoner Avatar asked Mar 15 '26 13:03

Disoner


1 Answers

For the Name to be displayed instead of the username part of the email, just do

from_email = "[email protected] <[email protected]>"

OR

from_email = "Name <[email protected]>"
like image 114
karthikr Avatar answered Mar 18 '26 03:03

karthikr



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!