You can use Anvil to send email via your GMail account.
To send emails via your Gmail account, you first need to enable the Gmail service.
In the App Browser, click the ‘+’ next to Services, then select ‘Google API’. In the Google API dialog, expand the section named ‘Send email from your GMail address’, and click ‘Enable email’:
You’ll be prompted to log in and connect your GMail account.
Once you’ve enabled the GMail service, you can send emails via your GMail account from code. Here is a simple example, sending a text-only email to one address.
import anvil.google.mail anvil.google.mail.send( to = "Sarah <firstname.lastname@example.org>", subject = "Meeting today", text = "See you at 5pm")
Here is a more complex example, illustrating all the possible parameters to
from_address- The email address from which this email is sent. Must be a string. You can add a name to the From field with a string like
"Name <email@example.com>". (You can specify any name, but the email address must be an address registered to this GMail account.)
to- The email address(es) this email is sent to. Can be a string or a list of strings.
cc- The email address(es) to which this email is CCed. Can be a string or a list of strings.
bcc- The email address(es) to which this email is Blind CCed. Can be a string or a list of strings.
subject- The subject line of the email
text- The plain text of the email. You must specify either text or html (or both).
html- An HTML-formatted version of the email. You must specify either text or html (or both).
anvil.google.mail.send( from_address = "Al <firstname.lastname@example.org>", to = ["email@example.com", "Bob <firstname.lastname@example.org>"], cc = "email@example.com", bcc = "firstname.lastname@example.org", subject = "Meeting today", text = """ Dear all, There will be a meeting today at 5pm. Best Regards, Joseph """, html = """ Dear all, <p>There will be a meeting today at <b>5pm</b>. <p>Best regards, <p>Joseph """)