25 lines
610 B
Python
25 lines
610 B
Python
import secrets
|
|
|
|
from fastapi_mail import MessageSchema, MessageType
|
|
|
|
from http2smtp.smtp import send_email
|
|
|
|
|
|
def test_send_email():
|
|
"""Test that we can send e-mail without SSL/TLS"""
|
|
# GIVEN: A valid login to the server
|
|
from_address = 'test@example.com'
|
|
password = secrets.token_urlsafe(8)
|
|
|
|
message = MessageSchema(
|
|
subject='Test e-mail',
|
|
recipients=['another@example.com'],
|
|
body='This is the body',
|
|
subtype=MessageType.plain
|
|
)
|
|
|
|
# WHEN: An e-mail is sent
|
|
send_email(from_address, password, message)
|
|
|
|
# THEN: The message should have been sent
|