Strange behaviour with e-mails between Django and Google - django

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.

Related

Paypal Sandbox not sending IPN back to django through ngrok tunnel, but works fine on IPN Simulator

I have a django app that uses django-paypal to manage payments and trigger certain actions using signals.py when the payment is received
#receiver(valid_ipn_received)
def payment_notification(sender, **kwargs):
ipn = sender
if ipn.payment_status == 'Completed':
# payment was successful, do something
In order to test it locally, I'm using ngrok to expose the local server to Paypal services.
Using the IPN Simulator everything is working fine and the signal in the django platform is triggered.
However, when I interact with the sandbox under the same conditions, I am not receiving the IPN back from Payal after the payment is completed. From the sandbox business account dashboard I can see the payment is received, but looking at the IPN History from the same account I notice that Paypal is not able to send the IPN, claiming a "failed operation" without further information (not even an error code from the server).
The strangest thing is that the sandbox flow was working like a charm until two days ago. Now I am only able to test through the IPN Simulator.
What am I doing wrong?
While not exactly a technical solution, I think its worth keeping track of how this problem was solved. Turned out there was a bug on the Paypal side, so as Patryk SzczepaƄski suggested in the comments, what worked here was contacting Paypal technical support. They solved the problem in a matter of hours.

Email verification not working with deployed django app on heroku

I've deployed a django website with Heroku. When a user creates an account in the app, a validation email is supposed to be sent. Do do that, I'm using smtp from gmail, and in my account settings, I've activated "less secure app access".
This works perfectly fine on my local machine, but when using the deployed app, I can't get the email to be sent.
The first time, I got a security warning from google saying someone connected to my account. I said it was me and tried again. I didn't get any other security warning but it seems the app is still unable to send emails.
Please, let me know if you have any idea what the issue might be.
Thanks.

Django mail failed to send mail to icloud mail id

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?

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 registration email never arrives

I am using django registration to handle um... registration on a site I'm building. I'm running on ubuntu and I've installed postfix and dovecot and maybe some other email apps that I don't fully understand (I used these instructions).
So now I'm pretty sure the postfix server is working. On the system shell I can do:
$ mail -s 'test' pete#example.com
and I get an email 30 nano seconds later. Similarly, in the django shell I can issue:
>>> send_mail('Subject here', 'Here is the message.', 'service#example.com',['pete#example.com'],fail_silently=False)
and I get another email. But, the registration app still never seems to get an email out. I'm at a loss for where to start debugging this, so any advice would be greatly appreciated.
PS: i've completed all the django registration required templates
Did you check if you application sends the mail correctly using python's DebuggingServer? See my answer to another question for some details.
Alternatively you could try Django's ConsoleBackend for debugging the sending of mails.
Additionally you could try sending mails using your mail provider.