"i am trying send email using web2py with gmail and using smtp setting i have attached all code" Code Answer

3

before using mail.send() i would recommend to test if mail is correctly set :

if form.process().accepted:
    session.name = form.vars.name
    session.email = form.vars.email
    session.subject = form.vars.subject
    session.message = form.vars.message
    if mail:
        if mail.send(to=['otheremail@yahoo.com'],
            subject='project minerva',
            message= "hello this is an email send from minerva.com from contact us form.nname:"+ session.name+" nemail : " + session.email +"nsubject : "+session.subject +"nmessage : "+session.message+ ".n "
        ):
            response.flash = 'email sent sucessfully.'
        else:
            response.flash = 'fail to send email sorry!'
    else:
        response.flash = 'unable to send the email : email parameters not defined'
elif form.errors:
        response.flash='form has errors.'

then try to change :

mail.settings.server = 'smtp@gmail.com:465'

in

mail.settings.server = 'smtp.gmail.com:465'

or

mail.settings.server = 'smtp.gmail.com:587'
By Aubergine on May 7 2022

Answers related to “i am trying send email using web2py with gmail and using smtp setting i have attached all code”

Only authorized users can answer the Search term. Please sign in first, or register a free account.