Django mail failed to send mail to icloud mail id - django

I used the below code
from django.core.mail import EmailMessage
email = EmailMessage('Hello', 'World', to=['user#gmail.com'])
email.send()
the message is sent when I used any other mail except icloud, the code says the message has been sent but I didn't receive any message.
Is this Django issue or some policies of icloud is blocking it?

If it works with other mails, than it's most likely an ICloud thing.
Gmail for example considers the SMPT Api as less secure than their G-Mail Api. In order be able to use it you need to grant access for less secure apps maybe there's a similar thing in ICloud.
Stupid question: Have you looked in your spam folder?

Related

Strange behaviour with e-mails between Django and Google

I have configured my Django settings to send an e-mail using gmail (for password reset)
However, I'm facing a strange behaviour from Google:
Locally, it works fine, when I use my Django app and I get the report that an email has been sent;
Deployed on DigitalOcean, using the shell, it works fine:
>>> from django.core.mail import send_mail
>>> send_mail("Objet3", "Message body", "from.eg#gmail.com",['to.eg#gmail.com'], fail_silently=False)
1
However, when using the deployed app, I always get a Server Error 500, which is reported as such by Sentry:
SMTPSenderRefused: (530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError f6sm10267338edk.13 - gsmtp', 'webmaster#localhost')
It's really puzzling, as at Gmail:
I have decreased the level of security,
I have created an App pass and implemented it...
Does anyone have an idea, where it may come from ?
Google does not want to be an email provider like this so they've made it increasingly difficult. Look into a provider such as sendgrid, mailgun, or others.
Finally SendGrid was a reasonable and practical solution, as I could configure it to :
send e-mails with my own domain name,
certify the e-mail so it doesn't fall into the spams
and they have a plan for free, absolutely useful in development phase.
Thank you Schillingt for your piece of advice.

Revert emails fetched via django-mailbox, back to Gmail inbox

I am a Django newbie. I have setup a mailbox in Django admin using the django-mailbox package. The URI configuration was a Gmail IMAP email server. While retrieving mails into my Django mailbox, they got deleted from the inbox and got created as db records. Is there a way to revert the emails back to the Gmail inbox, either using a Django API, gsuite's email recovery, or exporting data from db into Gmail inbox?
Thanks in advance for your help.
P.S. the mails are not present in the trash folder.
You might try iterating over each django_mailbox.Message
instance, use the get_email_object method to help generate a MIME message, then use IMAP APPEND to put the message back in your online mailbox.

How to configure Django such that emails are sent by both smtp, and to a log file?

I'm frequently plagued by the complaints that email from a django application running on its own Ubuntu LTS 16.04 server, is not being received. Typically these are the password change request emails, so they're part of the standard Django Auth module as I understand it.
Django's sendtestemail appears to work reliably, and many of the expected emails are actually sent and received (from what we can discern). The smtp setup is such that EMAIL_HOST is set to an smtp server on the same network that supports anonymous message relay (from servers on the same network only), and the EMAIL_BACKEND is the typical django.core.mail.backends.smtp.EmailBackend. Using the console backend for testing shows that emails are triggered as we would expect on these various events.
So, what I want to be able to do, is to have both email sent out via the smtp relay as expected, but also be added to a log file, and for this to happen for all emails generated by all the email events in the Django app.
Is this possible using django configuration?
If not, can you recommend a method by which I can both send and log the emails?
Bonus query - can the solution allows me to resend an email using the original content?

Emails sent using SendGrid on Heroku Django app to #gmail.com addresses seem to be blocked

I have a django app on heroku an using sendgrid.
I have gotten messages from a number of users with gmail email addresses saying that they have not received their validation emails after registering to use the site.
I tested it myself, and found that while emails with other addresses go through instantly, but for some gmail accounts it is not going through.
In the sendgrid dashboard, however, it says that all the emails have been delivered.
Can someone tell me what the issue here is? Is gmail blocking emails from my site? It just started happening these last two days. And we're not really sending out that many emails (10 or so a day)
Do the Emails end up in a spam folder, or do they truly disappear?
What kind of plan are you on at SendGrid? If you have your own dedicated IP, have you followed the guidelines on 'warming up' that IP address? Might also want to review the content of the message with SendGrid support, see if they can make any recommendations.
Emails end up in the spam folder. Whenever an email was sent from Heroku, Sendgrid to #gmail accounts, they were viewed as spam by Gmail.
I have the same problem and did not find a solution yet.

django send_mail get result

How can i get django send_mail result of email send. I run it local, i do send_mail to my email, and it return True, but letter not sended (because i have not any smtp set). But result is True. How to get real result?
Django uses exceptions to handle email sending problems. The value returned by send_mail is the number of emails that were sent.
If you're not getting an exception, it could be one of a number of things:
You have fail_silently set to True (default is False)
You're using a different email backend (smtp is the default for 1.2+, the only option for earlier versions)
The mail is actually being sent, but something else is wrong (email server, bad email address, spam folders, gmail self-sent mail hiding etc)
Use django-mailer. It puts the emails in the database and uses a cron-jobbed management command to send it out. It will help you track this issue down, improve your app response time, and also make your life easier.
I would also suggest to use exceptions to find out whether email was sent or not.
If you haven't time or option to set up an email server I would suggest to use django+gmail. U can create a 'fake' gmail account (create another one if you already own gmail-acc, it could be 'baned') and use its SMTP as a opportunity to send emails, even if you're working with django's development server (localy). How to is here