PR comments

This commit is contained in:
Adrià Casajús 2022-04-28 15:03:14 +02:00
parent 9a04376894
commit f9a390c1a2
No known key found for this signature in database
GPG Key ID: F0033226A5AFC9B9
1 changed files with 11 additions and 11 deletions

View File

@ -4,7 +4,7 @@ from mailbox import Message
from smtplib import SMTP, SMTPServerDisconnected, SMTPRecipientsRefused from smtplib import SMTP, SMTPServerDisconnected, SMTPRecipientsRefused
from typing import Optional, Dict from typing import Optional, Dict
import newrelic import newrelic.agent
from attr import dataclass from attr import dataclass
from app.config import ( from app.config import (
@ -20,8 +20,8 @@ from app.message_utils import message_to_bytes
@dataclass @dataclass
class SendRequest: class SendRequest:
from_address: str envelope_from: str
to_address: str envelope_to: str
msg: Message msg: Message
mail_options: Dict = {} mail_options: Dict = {}
rcpt_options: Dict = {} rcpt_options: Dict = {}
@ -73,15 +73,15 @@ class MailSender:
# encode message raw directly instead # encode message raw directly instead
LOG.d( LOG.d(
"Sendmail mail_from:%s, rcpt_to:%s, header_from:%s, header_to:%s, header_cc:%s", "Sendmail mail_from:%s, rcpt_to:%s, header_from:%s, header_to:%s, header_cc:%s",
send_request.from_address, send_request.envelope_from,
send_request.to_address, send_request.envelope_to,
send_request.msg[headers.FROM], send_request.msg[headers.FROM],
send_request.msg[headers.TO], send_request.msg[headers.TO],
send_request.msg[headers.CC], send_request.msg[headers.CC],
) )
smtp.sendmail( smtp.sendmail(
send_request.from_address, send_request.envelope_from,
send_request.to_address, send_request.envelope_to,
message_to_bytes(send_request.msg), message_to_bytes(send_request.msg),
send_request.mail_options, send_request.mail_options,
send_request.rcpt_options, send_request.rcpt_options,
@ -110,8 +110,8 @@ mail_sender = MailSender()
def sl_sendmail( def sl_sendmail(
from_address: str, envelope_from: str,
to_address: str, envelope_to: str,
msg: Message, msg: Message,
mail_options=(), mail_options=(),
rcpt_options=(), rcpt_options=(),
@ -120,8 +120,8 @@ def sl_sendmail(
ignore_smtp_error=False, ignore_smtp_error=False,
): ):
send_request = SendRequest( send_request = SendRequest(
from_address, envelope_from,
to_address, envelope_to,
msg, msg,
mail_options, mail_options,
rcpt_options, rcpt_options,