Closed pepegc closed 2 years ago
Ok I'm pretty sure it's because the api in local host is not secure enough for Google (no https). Is there a way to run the app with uvicorn with a https flag or something? For a second I thought adding HTTPSRedirectMiddleware
would help but that's just throwing me warnings and errors.
WARNING: Invalid HTTP request received.
[...]
h11._util.RemoteProtocolError: illegal request line
Ok I'm pretty sure it's because the api in local host is not secure enough for Google (no https). Is there a way to run the app with uvicorn with a https flag or something? For a second I thought adding
HTTPSRedirectMiddleware
would help but that's just throwing me warnings and errors.WARNING: Invalid HTTP request received. [...] h11._util.RemoteProtocolError: illegal request line
i do not think thats problem, we do not have problem send mails when run locally with http, but one our developer has same problem on her network, when she try mobile net then it works, so look like you have some firewall block on router or something, maybe it helps
It's fixed now but maybe you can explain why because I'm not sure and just continued working on something else: the problem was the value I had for MAIL_USERNAME. Turns out it started working when I set MAIL_USERNAME to be the sender email, which wasn't obvious because the email was already set in MAIL_FROM. So basically it works when MAIL_USERNAME = MAIL_FROM = my_email@gmail.com
we have same value for MAIL_USERNAME
and MAIL_FROM
but same result on her network soo but she cant access some others pages also ..
about MAIL_FROM i think it do not need to be same, but you need "access" to that mail from smtp acc, in gmail i can add mail alias like (my personal mail) and then change MAIL_FROM to my mail then all mail are send with smtp acc but with my mail as from
Hi there!
Locally should everything work fine, being said that you don't need to run your application with a TLS certificate unless your mail configuration requires it and you may have to set it while establishing connection.
MAIL_FROM_NAME
parameter is used to specify upon receiving the email to show from whom you have received the email.
MAIL_USERNAME
is the one that needs to be specified for establishing connections. You have to set this parameter.
MAIL_FROM
has been set, because some email providers use different sender email addresses, this param is not used for connection at all but MAIL_USERNAME
does do that.
I think we are all good with finding and resolving the issue, I will kindly close the issue if you face another issue feel free to open it. And thanks @filipagh for your help also.
I am getting the following error when trying the first basic example here:
fastapi_mail.errors.ConnectionErrors: Exception raised (535, '5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials l33-20020a0568302b2100b005cdad9100desm5879477otv.40 - gsmtp'), check your credentials or email service configuration
I tried with personal mail/pwd for testing and didn't work. Then I tried with validated mail/pwd currently being used in production on another (flask) app and it didn't work.