You can use the sendgrid smtp server or their api.
https://sendgrid.com/blog/which-protocol-should-i-use-to-send-email-smtp-or-rest/

Here is my logic for using their api (I also use mailgun with I like also):

def send_email_via_sendgrid(email_to, email_subject, email_body):
    # https://github.com/sendgrid/sendgrid-python

    import sendgrid
    from sendgrid import SendGridError, SendGridClientError, 
SendGridServerError

    sg = sendgrid.SendGridClient('<your sendgrid account>', '<your sendgrid 
pwd>', raise_errors=True)

    message = sendgrid.Mail()
    message.add_to(email_to)
    message.set_subject(email_subject)
    message.set_html(email_body)
    #message.set_text('Body')
    message.set_from('Your Name <us...@myweb2pyapp.com>')
    #status, msg = sg.send(message)

    try:
        sg.send(message)
    # raise SendGridClientError
    except SendGridClientError:
        pass
    except SendGridServerError:
        pass
    finally:
        return_code = response.status
        return locals()


On Wednesday, April 13, 2016 at 12:48:13 PM UTC-4, Krishna Bavandlapally 
wrote:
>
> Thank you Leonel Câmara.
>
> It worked.
>
> mail.settings.server = 'smtp.sendgrid.net:587'
> mail.settings.sender = xxx...@mail.com <javascript:>
> mail.settings.login = 'sendgrid_username:sendgrid_password'
> mail.settings.tls = True
>
>
>
> On Wednesday, 13 April 2016 14:29:16 UTC+5:30, Krishna Bavandlapally wrote:
>>
>> How to integrate (default mailing) SendGrid in Web2py ?
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to