0
0
Flaskframework~10 mins

Sending simple emails in Flask - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Flask-Mail extension.

Flask
from flask_mail import [1]
Drag options to blanks, or click blank then click option'
AMessage
BMail
CEmail
DFlaskMail
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Message instead of Mail
Using wrong class name like FlaskMail
2fill in blank
medium

Complete the code to create a Flask-Mail instance with the Flask app.

Flask
mail = [1](app)
Drag options to blanks, or click blank then click option'
AFlaskMail
BMessage
CMail
DEmail
Attempts:
3 left
💡 Hint
Common Mistakes
Using Message instead of Mail to create instance
Using wrong class name like FlaskMail
3fill in blank
hard

Fix the error in the code to create an email message with subject and recipients.

Flask
msg = Message(subject='Hello', recipients=[1])
Drag options to blanks, or click blank then click option'
A'user@example.com'
B{'user@example.com'}
Cuser@example.com
D['user@example.com']
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a list
Using a set or dictionary instead of a list
4fill in blank
hard

Fill both blanks to set the email body and send the message.

Flask
msg.body = [1]
mail.[2](msg)
Drag options to blanks, or click blank then click option'
A'This is a test email.'
Bsend
Csendmail
D'Email body text'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendmail instead of send
Setting body to a variable instead of a string
5fill in blank
hard

Fill all three blanks to configure Flask-Mail settings for SMTP server.

Flask
app.config['MAIL_SERVER'] = [1]
app.config['MAIL_PORT'] = [2]
app.config['MAIL_USE_TLS'] = [3]
Drag options to blanks, or click blank then click option'
A'smtp.gmail.com'
B587
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong port number
Setting MAIL_USE_TLS to False when TLS is needed