0
0
Flaskframework~10 mins

Flask-Mail setup - 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'
AMailSender
BMail
CMailer
DMailClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Mailer' or 'MailSender' which are not valid classes in flask_mail.
Trying to import from 'flask_mail.mail' instead of 'flask_mail'.
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'
AMail
BMailSender
CMailer
DMailClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using a class name other than 'Mail'.
Forgetting to pass the Flask app object.
3fill in blank
hard

Fix the error in the configuration key for the mail server address.

Flask
app.config['MAIL_[1]'] = 'smtp.example.com'
Drag options to blanks, or click blank then click option'
AHOST
BURL
CADDRESS
DSERVER
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'MAIL_HOST' or 'MAIL_ADDRESS' which are invalid keys.
Misspelling 'SERVER'.
4fill in blank
hard

Fill both blanks to set the mail username and password in the Flask app config.

Flask
app.config['MAIL_[1]'] = 'user@example.com'
app.config['MAIL_[2]'] = 'securepassword'
Drag options to blanks, or click blank then click option'
AUSERNAME
BPASSWORD
CUSER
DPASS
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'MAIL_USER' or 'MAIL_PASS' which are not recognized by Flask-Mail.
Mixing up the order of username and password keys.
5fill in blank
hard

Fill all three blanks to create and send a simple email message using Flask-Mail.

Flask
from flask_mail import Message

msg = Message(subject='Hello', sender='from@example.com', recipients=['to@example.com'])
msg.body = '[1]'

with app.app_context():
    [2].send([3])
Drag options to blanks, or click blank then click option'
Amail
Bmail.send
C'This is a test email.'
Dmsg
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the body to the mail instance or message object instead of a string.
Calling send on the message object instead of the mail instance.
Forgetting to use app context when sending.