Can’t send email in Django with

Even though I have a paid account, pythonanywhere is blocking my emails sent through

The email works perfectly in development, but in production it doesn’t go through. Is there any way around this!?

I would really appreciate some advice on how to fix this? Can I somehow send my emails from a different host?

We don't block anything from paid accounts -- your code connects directly to the Internet without any of our code getting in the way. What error message do you get when you try to connect to the Office365 servers?

Having the same problem - can send emails with in dev but not in production on PA.

Did anything more come to light on this?

I have a paid account so it's not due to free account restrictions.

If you're getting failures in one web app and not another, look in the error and server logs of the web app where it's failing to find tracebacks that you can use to start debugging.

Hi Glenn

Not seeing any errors in the error or server log. And nothing in the console that I'm running the script from either. I did put a couple of print statements in the email sending module and they were triggered, but the email bit appears to not be getting triggered (I'm not receiving the email).

I'm not sure if it makes a different, but the code that is responsible for sending the emails isn't part of my web app (a Django app)? I.e. they are standalone scripts that I am going to schedule to run daily and send an email if conditions are met.

Should that make a difference?

Edit: Saying that, the contact form that is done via Django is not working either.

As a person who hates Microsoft and Django, your post triggers me a lot

Sorry about that dull! :-)

Any ideas? It's almost like the emails are being sent (no errors) but Office365 is blocking/not distributing the emails that originate from PA (works fine on local machine) - is that feasible?

Ok have found the problem, there are bounce back emails in the account that they are being sent from:

Remote Server returned '550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP.

OK, so it does sound like Office365 is blocking the IP of the server where your code is running. Sometimes services block stuff from cloud service providers to try to reduce spam.

What kind of account do you have with MS to provide the SMTP service on Office365? Is there perhaps some way you can ask them to whitelist IPs?

Hi Giles

It was the email service offered by GoDaddy. I figured it would be easier to move to another service than try and get MS to whitelist and it's all running fine with Namecheap's service.

OK -- glad you found a solution!