mail.send_mail(sender=sender_address,to="Albert Johnson <Albert.Johnson@example.com>",subject="Your account has been approved",body="""Dear Albert:Your example.com account has been approved. You can now visithttp://www.example.com/ and sign in using your Google Account toaccess new features.Please let us know if you have any questions.The example.com Team""")
message=mail.EmailMessage(sender=sender_address,subject="Your account has been approved")message.to="Albert Johnson <Albert.Johnson@example.com>"message.body="""Dear Albert:Your example.com account has been approved. You can now visithttp://www.example.com/ and sign in using your Google Account toaccess new features.Please let us know if you have any questions.The example.com Team"""message.send()
次の例は、メールアドレスを確認するメッセージの送信を示しています。
classUserSignupHandler(webapp2.RequestHandler):"""Serves the email address sign up form."""defpost(self):user_address=self.request.get('email_address')ifnotmail.is_email_valid(user_address):self.get()# Show the form again.else:confirmation_url=create_new_user_confirmation(user_address)sender_address=('Example.com Support <{}@appspot.gserviceaccount.com>'.format(app_identity.get_application_id()))subject='Confirm your registration'body="""Thank you for creating an account!Please confirm your email address by clicking on the link below:{}""".format(confirmation_url)mail.send_mail(sender_address,user_address,subject,body)
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-13 UTC。"],[[["The mail API offers two methods for sending emails: the `mail.send_mail()` function and the `EmailMessage` class."],["Email sending is asynchronous, meaning the function or method returns immediately after sending the message data to the mail service, which then queues and attempts delivery."],["To use this API you need to register your sender emails as authorized senders."],["The `mail.send_mail()` function takes email fields as parameters, whereas the `EmailMessage` class uses attributes of an instance to construct and send emails."],["This API can only run in first-generation runtimes in the App Engine standard environment."]]],[]]