@@ -825,6 +825,7 @@ class SimSMTPServer(smtpd.SMTPServer):
825825
826826 def __init__ (self , * args , ** kw ):
827827 self ._extra_features = []
828+ self ._addresses = {}
828829 smtpd .SMTPServer .__init__ (self , * args , ** kw )
829830
830831 def handle_accepted (self , conn , addr ):
@@ -833,7 +834,8 @@ def handle_accepted(self, conn, addr):
833834 decode_data = self ._decode_data )
834835
835836 def process_message (self , peer , mailfrom , rcpttos , data ):
836- pass
837+ self ._addresses ['from' ] = mailfrom
838+ self ._addresses ['tos' ] = rcpttos
837839
838840 def add_feature (self , feature ):
839841 self ._extra_features .append (feature )
@@ -1072,6 +1074,21 @@ def test_send_unicode_without_SMTPUTF8(self):
10721074 self .assertRaises (UnicodeEncodeError , smtp .sendmail , 'Alice' , 'Böb' , '' )
10731075 self .assertRaises (UnicodeEncodeError , smtp .mail , 'Älice' )
10741076
1077+ def test_name_field_not_included_in_envelop_addresses (self ):
1078+ smtp = smtplib .SMTP (
1079+ HOST , self .port , local_hostname = 'localhost' , timeout = 3
1080+ )
1081+ self .addCleanup (smtp .close )
1082+
1083+ message = EmailMessage ()
1084+ message ['From' ] = email .utils .formataddr (('Michaël' , 'michael@example.com' ))
1085+ message ['To' ] = email .utils .formataddr (('René' , 'rene@example.com' ))
1086+
1087+ self .assertDictEqual (smtp .send_message (message ), {})
1088+
1089+ self .assertEqual (self .serv ._addresses ['from' ], 'michael@example.com' )
1090+ self .assertEqual (self .serv ._addresses ['tos' ], ['rene@example.com' ])
1091+
10751092
10761093class SimSMTPUTF8Server (SimSMTPServer ):
10771094
0 commit comments