@@ -107,17 +107,18 @@ def _create_email(self, email: dict, email_id: str) -> Mail:
107107 # so that the email still gets routed back to the original client
108108 # ...this is a pretty ugly hack and the real fix is to change the logic of
109109 # how we sign up users on clients to use the new format {user}-{client}@{domain}
110- from_email = email ['from' ]
111- user , client_domain = from_email .split ('@' )
112- client_domain_parts = client_domain .split ('.' )
113- if len (client_domain_parts ) == 3 :
114- client = client_domain_parts [0 ]
115- domain = '.' .join (client_domain_parts [1 :])
116- mail .from_email = Email ('{}-{}@{}' .format (user , client , domain ))
117- mail .reply_to = Email (from_email )
118- else :
119- mail .from_email = Email (from_email )
120- self .log_debug ('added from to email %s' , email_id )
110+ from_email = email .get ('from' )
111+ if from_email :
112+ user , client_domain = from_email .split ('@' )
113+ client_domain_parts = client_domain .split ('.' )
114+ if len (client_domain_parts ) == 3 :
115+ client = client_domain_parts [0 ]
116+ domain = '.' .join (client_domain_parts [1 :])
117+ mail .from_email = Email ('{}-{}@{}' .format (user , client , domain ))
118+ mail .reply_to = Email (from_email )
119+ else :
120+ mail .from_email = Email (from_email )
121+ self .log_debug ('added from to email %s' , email_id )
121122
122123 for i , attachment in enumerate (email .get ('attachments' , [])):
123124 mail .add_attachment (self ._create_attachment (attachment ))
0 commit comments