gmail smtp and password retrieval

48 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

lucas

lukematon,
17.8.2022 klo 11.20.4917.8.2022
vastaanottaja web2py-users
hey one and all,

on May 5th, 2022, gmail imposed the 2 step verification on its smtp service.  how do we configure web2py to still use our gmail accounts to send smtp for password retrieval.

thank you in advance, lucas

Clemens

lukematon,
17.8.2022 klo 11.34.5817.8.2022
vastaanottaja web2py-users
Generate an app password, as follows:
https://support.google.com/mail/answer/185833?hl=en

This should solve it, hopefully.

Regards
Clemens

lucas

lukematon,
17.8.2022 klo 11.54.3817.8.2022
vastaanottaja web2py-users
ok, i turned on 2-step verification, generated 1 password for "App passwords" that gave me a 16 character string which i copied into the password location under private/appconfig.ini:

server = smtp.gmail.com:465
sender = profes...@gmail.com
login  = 'profes...@gmail.com:eakwlqljrsdeyj16'
tls    = true
ssl    = true

where i changed the login string so i didn't give away my security.  so what do you think?
lucas

lucas

lukematon,
17.8.2022 klo 11.57.5617.8.2022
vastaanottaja web2py-users
oh, so the latter is still not sending the Lost Password.

Clemens

lukematon,
17.8.2022 klo 12.08.1217.8.2022
vastaanottaja web2py-users
Hmm, should work, since it's the right port for ssl. Maybe setting tls to false could make it work, since the tls port is 587.

Have a try! Hope it helps!

Clemens

lucas

lukematon,
17.8.2022 klo 12.12.5017.8.2022
vastaanottaja web2py-users
nope, that didn't work either.  uhmmmmm.

Clemens

lukematon,
17.8.2022 klo 12.15.5217.8.2022
vastaanottaja web2py-users
Hmmmmm, one last guess: ssl false, tls true and port 587.

lucas

lukematon,
17.8.2022 klo 12.18.1617.8.2022
vastaanottaja web2py-users
nope, and i regenerated a new password just to be sure and restarted the server daemons also.  just in case appconfig is only loaded once.

lucas

lukematon,
17.8.2022 klo 20.54.2217.8.2022
vastaanottaja web2py-users
i'm wondering.  do i have to retrieve or generate the 16 digit password from the app itself.  cuz i don't know how to do that since it is purely a linux console only interface.

lucas

lukematon,
17.8.2022 klo 22.07.4017.8.2022
vastaanottaja web2py-users
i am using web2py 2.22.5 using the wsgihandler.py handler and nginx under centos 8 stream all current and updated and rebooted.  i don't understand all of the stuff from massimo

jonatha...@whatho.net

lukematon,
18.8.2022 klo 2.24.4218.8.2022
vastaanottaja web2py-users
I'm using web2py 2.22.3. My only email settings in db.py are are:

## configure email
mail=auth.settings.mailer
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = '********@gmail.com'
mail.settings.login = '********@gmail.com:################'

The length 16 password is the app password generated by gmail. Emails work, used mainly by auth to send
reset-password links.

Here's a little python snippet to test your userid / password work with gmail.

import imaplib
import sys

def checkGmail(userid, password):
'''
get unread email count and spam count from gmail
'''
    try:
        session = imaplib.IMAP4_SSL('imap.gmail.com')
        session.login(userid, password)
        session.select()
        unseen_inbox = len(session.search(None, 'UNSEEN')[1][0].split())
        rc = session.select('[Gmail]/Spam')
        if rc[0] == 'OK':
            spam = int(rc[1][0])
        else:
            spam = '0'
        return(True, unseen_inbox, spam)
    except:
        print(("Unexpected error:", sys.exc_info()))
        return (False,)

if __name__ == '__main__':
    print (checkGmail('**********@gmail.com', '################'))

When I run this with the userid and password set in my db.py file I get (True, 30, 5), demonstrating that I can log in to gmail with the userid and app password. Does it work for you?
Vastaa kaikille
Vastaa kirjoittajalle
Välitä
0 uutta viestiä