I am sure details.email_address is defined, I double checked.

I redefined my code & added the highlighted lines,  now everytime i send 
the email response flashes an error message. How can I get it to tell me 
the exact error??

def contact_us():
    details=db.hotel_profile(request.args(0, cast=int))
    form = SQLFORM.factory(
    Field('name', requires=IS_NOT_EMPTY()),
    Field('cell_number', requires=IS_NOT_EMPTY()),
    Field('email', requires =[ IS_EMAIL(error_message='invalid email!'), 
IS_NOT_EMPTY() ]),
    Field('subject', requires=IS_NOT_EMPTY()),
    Field('message', requires=IS_NOT_EMPTY(), type='text')
    )
    
*    sent = False*
    if form.process().accepted:
        *sent = mail.send(to='details.email_address', *
                  #subject='contact request from %(your_name)s %(email)s' 
 % form.vars,
                  subject=form.vars.subject,
                  message = '%(message)s \nName: %(name)s \nEmail Address: 
%(email)s \nCell Number: %(cell_number)s' % form.vars)

    response.flash = T('Thank you, your form was submitted')
    
*    if not sent:*
*        response.flash = 'Error sending message, please use email.'       
 *
    return dict(form=form)

Regards;


On Sunday, February 23, 2020 at 8:03:04 PM UTC+2, Scott Hunter wrote:
>
> What error did it give you?  Are you sure `details.email_address` is 
> defined?
>
> On Sunday, February 23, 2020 at 8:13:07 AM UTC-5, mostwanted wrote:
>>
>> I did try  it without the quotes & it still gave me an error!
>>
>> On Sunday, February 23, 2020 at 2:59:04 PM UTC+2, Scott Hunter wrote:
>>>
>>> Did you try removing the quotes around the address?
>>>
>>> - Scott
>>>
>>>
>>>
>>> On Saturday, February 22, 2020 at 4:56:04 PM UTC-5, mostwanted wrote:
>>>>
>>>> I've created an emailing form in my application but have substituted 
>>>> where the email goes with a reference that contains the email, the problem 
>>>> is that now the email is not being sent unless i write a proper explicit 
>>>> email address. Whats the difference between writing an explicit email 
>>>> address & using a variable that supposedly contains the email? I have to 
>>>> use the referencing variable as I currently am because different 
>>>> registered 
>>>> users get to log in & send emails, its not just one user. How can I solve 
>>>> this problem???
>>>>
>>>> *CODE*
>>>> def contact_us():
>>>>     details=db.hotel_profile(request.args(0, cast=int))
>>>>     form = SQLFORM.factory(
>>>>     Field('name', requires=IS_NOT_EMPTY()),
>>>>     Field('cell_number', requires=IS_NOT_EMPTY()),
>>>>     Field('email', requires =[ IS_EMAIL(error_message='invalid email!'
>>>> ), IS_NOT_EMPTY() ]),
>>>>     Field('subject', requires=IS_NOT_EMPTY()),
>>>>     Field('message', requires=IS_NOT_EMPTY(), type='text')
>>>>     )
>>>>     if form.process().accepted:
>>>> *        mail.send(to='details.email_address', *
>>>>                   #subject='contact request from %(your_name)s 
>>>> %(email)s'  % form.vars,
>>>>                   subject=form.vars.subject,
>>>>                   message = '%(message)s \nName: %(name)s \nEmail 
>>>> Address: %(email)s \nCell Number: %(cell_number)s' % form.vars)
>>>>         response.flash = T('Thank you, your form was submitted')
>>>>         #redirect(URL('index'))
>>>>     return dict(form=form)
>>>>
>>>>
>>>> Regards;
>>>>
>>>> Mostwanted
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d76e2a08-a44b-4328-b1a1-c1ba13af53a1%40googlegroups.com.

Reply via email to