For users of our Django app that receive their emails through gmail they are finding that emails are getting grouped into conversations that shouldn't be.
I'm not sure what gmail expects in an email to consider it unique enough to not group as a conversation but when I send plain text emails with DIFFERENT subjects using send_mail or even try a multipart/alternative with EmailMultiAlternatives with an html body gmail still assumes they are part of the same conversation.
Obviously this creates confusion when our application sends emails with different subjects and bodies to the same user and they are all grouped and gmail only shows the subject of the first message in the conversation.
I have 100% confirmed by looking at the raw original email messages to make sure the emails are different subjects and bodies.
I just want to know if I can change anything in how django creates the email message so it can play nice with gmail conversations.
I am using python 2.7.4, and can replicate the "issue" with Django 1.4 and 1.5.
Make sure messages on different subjects have a different 'From' address
Related
I wish to setup a subscribe form. The user will fill his/her email address and on submit an email should be sent to the provided email address for verification. The verification email will have a link on which the user can click to verify the email address.
This form will be in a website which I plan to host at Bluehost.
I read this tutorial about how it can be done in Python. Following is a snippet from the tutorial
import smtplib
s = smtplib.SMTP(host='your_host_address_here', port=your_port_here)
s.starttls()
s.login(MY_ADDRESS, PASSWORD)
My question is will I able to make this work on Bluehost ?,
My understanding is that host and port can be obtained as described
in this link.
Also,is there any third-party service that allows me create such subscribe form as described above?
While this could technically work, I highly recommend using a third-party service to send the actual emails. These days, the chance of your email getting delivered if it's being sent from a random Bluehost server is quite low due to its low "email sender reputation".
Snippet from this link explaining it:
An email sender reputation is a score that an Internet Service Provider (ISP) assigns to an organization that sends email. It’s a crucial component of your email deliverability. The higher the score, the more likely an ISP will deliver emails to the inboxes of recipients on their network. If the score falls below a certain threshold, the ISP may send messages to recipients’ spam folders or even reject them outright.
Some email sending services include SendGrid or Amazon SES.
If your website is static, then please go for third party service beacuse it will be difficult for you to handle the backend and integration part. So, look for some third party applications to do it for you for example SendPulse
If your website is dynamic, i.e if its having some backend server part as well, then this email sending part can be done easily depending upon which language you are using at backend. Most languages has support for sending emails.
I have surfed the internet for a day but didn't find the perfect article which gives the best practices for sending mass emails.
I have configured Amazon SES using django-ses and mails are sending correctly. Now the problem is I don't know how people send mass mail, hide other recipients, which function they use, and what pattern they follow to make sending mass mail efficient and ease.
Also, we are using templates (Django Templates) for mail and below is the best solution I got by mixin all best things I found on the internet:
# 1. Getting queryset of all recipients which will receive mail
# (mine is a little bit different but at the end, it gives queryset of all emails - not list)
subscribers = EmailNotificationSubscriber.objects.all().values_list('user__user_email', flat=True)
# 2. Opening a connection
# 3. [Looping] using `.iterator()` to fetch email one by one from queryset (I think this is to handle the cases where we have an email list of around 10k or even bigger)
# 4. Creating EmailMessage instance and sending an email using `.send()`
# Function to get HTML Message (instance of `EmailMessage`)
def get_html_msg(subject, from_email, to, template_name, ctx, connection=None):
message = get_template(os.path.join(settings.BASE_DIR, 'templates', 'email', template_name)).render(ctx)
msg = EmailMessage(subject, message, from_email, to, connection=connection)
msg.content_subtype = 'html'
return msg
# Function which sends mass mail
def send_mass_mail(subject, qs, mail_template='base.html', ctx=None, fail_silently=True, *args, **kwargs):
from_email = settings.EMAIL_FROM
with get_email_connection() as connection:
for recipient in qs.iterator():
print(f"Sending to recipient: {recipient}")
msg = get_html_msg(subject, from_email, [recipient], mail_template, ctx, connection)
msg.send(fail_silently)
Above is what I am doing:
Getting just emails and not converting it into list so I can use .iterator()
Using a single connection to sending all mails
Hiding other recipient using loop by sending mail one by one
(I will use the same template for all recipient so I will refactor that for performance later)
So, How people send mass mail with Amazon SES? Do they use something else over this? An open-source repo or example would greatly help.
Thanks so much
Edit 1: Removed Emojis
Edit 2: Question Narrowed
according to Your questions i think that firstly, when sending mass mail, You should take into account the reputation of Your SES account which can drop down massively if You decide to buy a recipients email list. In order to achive that, it is good to use Dedicated IP's in SES. Here is link to that: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/dedicated-ip.html
According to Your questions:
The best way would be to include them in bcc header, as You have set, the limit can depends on SMTP server. According to the AWS, it is 50 recipient's per message. So what You can do is You can group all of the mails and make one call with 50 recipients so it would lower Your request amount significantly.
Mass mailing has two approaches. One that, You have already tried(so one by one, and the other one which is considered better -> sending in bulks, as described above). If You would like to check something about for instance bulk sending You can see it there: https://aws.amazon.com/blogs/messaging-and-targeting/introducing-email-templates-and-bulk-sending/ Also, it is good to use only BCC field. You are ensuring Yourself, that there will not be any mistakes in displaying to the recipients email addresses of the other users.
Check that links, that I have already provided.
Yes, it is. You can easily use amazon ses templates, or create Your own ones. Also, the customization, managing Your own domains, configuration sets is really helpful and the documentation is quite good. However there are small drawbacks, and some minor bugs(for instance when You verify the domain, and it doesn't work instantly, there is a possibility that removing and adding it one more time fixes it :) ) However You have to be careful about Your reputation on SES.
Practises:
Don't use TO/CC, instead use BCC
Always monitor Your sending reputation, unless You want Your account to be blocked
Invest in dedicated ips
Block emails, which had already bounced before(Amazon has it's own suppression list, however it is much better to have one more on Your side)
Be aware of the sending quota, that You already have assigned and extend it for Your purposes
Don't buy email list
You can verify recipient's emails address existence before email sending
Be aware of the compliaints
Don't use link shorteners
I have a service which sends emails with attached reports per schedule (daily, hourly, 30+ sendings in total in a cron job).
All emails come to a Gmail account inbox which is added to 'cc'.
I wonder if there a simple way to expect an email at some defined time and trigger another email if it didn't come or if it doesn't have an attachment?
php, python, java solutions will do
Here is a blog about "How to Read Email From Gmail Using Python": http://codehandbook.org/how-to-read-email-from-gmail-using-python/
Use a cron to read your emails periodically.
We are building a website expecting to serve around 10k users or more.
We want a functionality that each user will have an email address # our domain, however, this email address will not be accessible by the user it will only be used to receive a very rare amount of emails (say it will be published to receive gift cards directed to that user) and we need to notify the user as any gift card is received and do something accordingly at our end
We want to use Google App Engine with Python, and what first came to our minds is that we don't actually create any real mailboxes and we create a single catch-all email that will receive any mail sent to our domain mailboxes even not existed, then we can filter all received emails and map them to our users accounts
Within current Google receive limits (1 email per second) this will work, the main issue is that SPAM mails comes and flood the catch-all mail box with emails that directly reach receive limit and email account gets suspended by Google
We want to apply a smarter solution, we only care for emails that comes from a specific sender domain (say: giftcards.com) and we can drop any other emails
Is there is any reliable service or setup at our side we can use to filter out unwanted emails and only forward emails from giftcards.com (for example) to our main Google apps email?
I'm using django-socialregistration and facebook python sdk.
This is the code to get friends:
friends = request.facebook.graph.get_connections('me', 'friends')
I can get their name and id but I can't get their email address (not their #facebook.com email).
This is another attempt which also can't get their email.
for friend in friends['data']:
request.facebook.graph.get_object(friend['id'])
How can I get the facebook friends email?
It is possible to get the email of a user connected to your app using Graph. However, when connecting or signing in using Facebook users must explicitly give you permission to use their email address. Since none of the friends gave you permission, their e-mail addresses are off limits. What this means is you can encourage the user to have their friends join as well, and make sure that when they sign up you include a request for their e-mail address.
I think you are not getting the email from friends because this is not even possible to get from Facebook`s Graph API.
Check this out:
Facebook Graph API, how to get users email?