178👍
✅
You can actually use "Don't Reply <do_not_reply@domain.example>"
as the email address you send from.
Try this in the shell of your Django project to test if it also works with gapps:
>>> from django.core.mail import send_mail
>>> send_mail('subject', 'message', "Don't Reply <do_not_reply@domain.example>", ['youremail@example.com'])
0👍
Apart from the send_mail method to send email, EmailMultiAlternatives can also be used to send email with HTML content with text content as an alternative.
try this in your project
from django.core.mail import EmailMultiAlternatives
text_content = "Hello World"
# set html_content
email = EmailMultiAlternatives('subject', text_content, 'Dont Reply <do_not_reply@domain.example>', ['youremail@example.com'])
email.attach_alternative(html_content, 'text/html')
email.send()
This will send mail to youremail@example.com
with Don’t Reply wil be displayed as name instead of email do_not_reply@domain.example
.
- [Django]-Django CMS fails to synch db or migrate
- [Django]-Should I be adding the Django migration files in the .gitignore file?
- [Django]-Django: Adding "NULLS LAST" to query
-5👍
I use this code to send through gmail smtp (using google apps). and sender names are OK
def send_mail_gapps(message, user, pwd, to):
import smtplib
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(user, pwd)
mailServer.sendmail(user, to, message.as_string())
mailServer.close()
- [Django]-Django, creating a custom 500/404 error page
- [Django]-Referencing multiple submit buttons in django
- [Django]-Django 1.5 custom User model error. "Manager isn't available; User has been swapped"
Source:stackexchange.com