@@ -54,7 +54,8 @@ def load_templates():
5454 }
5555
5656
57- def send_email (config , to , subject , body , in_reply_to = None , dry_run = False ):
57+ def send_email (config , to , subject , body , in_reply_to = None , cc = None ,
58+ dry_run = False ):
5859 if dry_run :
5960 return False
6061
@@ -67,14 +68,15 @@ def send_email(config, to, subject, body, in_reply_to=None, dry_run=False):
6768 except (configparser .NoSectionError , configparser .NoOptionError ):
6869 return False
6970
70- cc = config .get ('ml-agent-smtp' , 'cc' , fallback = '' )
71+ config_cc = config .get ('ml-agent-smtp' , 'cc' , fallback = '' )
72+ all_cc = [a for a in [config_cc , cc ] if a ]
7173
7274 msg = MIMEText (body )
7375 msg ["Subject" ] = subject
7476 msg ["From" ] = from_addr
7577 msg ["To" ] = to
76- if cc :
77- msg ["Cc" ] = cc
78+ if all_cc :
79+ msg ["Cc" ] = ", " . join ( all_cc )
7880 if in_reply_to :
7981 msg ["In-Reply-To" ] = in_reply_to
8082 msg ["References" ] = in_reply_to
@@ -140,11 +142,19 @@ def check_known_developer(config, db, identity_id):
140142def process_email (msg , message_id , timestamp , config , db , templates ,
141143 dry_run = False , decisions = None ):
142144 from_hdr = msg .get ('From' , '' )
145+ reply_to_hdr = msg .get ('Reply-To' , '' )
143146 subject = msg .get ('Subject' , '' )
144147 name , email_addr = split_from (from_hdr )
145148 if not email_addr :
146149 return
147150
151+ if reply_to_hdr :
152+ send_to = reply_to_hdr
153+ send_cc = from_hdr
154+ else :
155+ send_to = from_hdr
156+ send_cc = None
157+
148158 identity_id = db .resolve_identity (name , email_addr )
149159
150160 pv_tags = extract_pv_bot_tags (msg )
@@ -166,9 +176,10 @@ def process_email(msg, message_id, timestamp, config, db, templates,
166176 dup = db .find_recent_duplicate (identity_id , title , timestamp )
167177 if dup :
168178 db .set_submission_warned (message_id , 1 )
169- send_email (config , from_hdr , f'Re: { subject } ' ,
179+ send_email (config , send_to , f'Re: { subject } ' ,
170180 templates ['resubmit-warn' ],
171- in_reply_to = message_id , dry_run = dry_run )
181+ in_reply_to = message_id , cc = send_cc ,
182+ dry_run = dry_run )
172183 if decisions is not None :
173184 decisions .append (('resubmit-warn' , email_addr , title ))
174185
@@ -177,9 +188,10 @@ def process_email(msg, message_id, timestamp, config, db, templates,
177188 _ , welcomed = db .get_identity (identity_id )
178189 if not welcomed :
179190 db .set_welcomed (identity_id )
180- send_email (config , from_hdr , f'Re: { subject } ' ,
191+ send_email (config , send_to , f'Re: { subject } ' ,
181192 templates ['welcome' ],
182- in_reply_to = message_id , dry_run = dry_run )
193+ in_reply_to = message_id , cc = send_cc ,
194+ dry_run = dry_run )
183195 if decisions is not None :
184196 decisions .append (('welcome' , email_addr , title ))
185197 else :
@@ -197,9 +209,10 @@ def process_email(msg, message_id, timestamp, config, db, templates,
197209 prev = db .find_previous_version (identity_id , title , version )
198210 if prev :
199211 db .set_submission_warned (prev [0 ], 2 )
200- send_email (config , from_hdr , f'Re: { subject } ' ,
212+ send_email (config , send_to , f'Re: { subject } ' ,
201213 templates ['threaded-warn' ],
202- in_reply_to = message_id , dry_run = dry_run )
214+ in_reply_to = message_id , cc = send_cc ,
215+ dry_run = dry_run )
203216 if decisions is not None :
204217 decisions .append (('threaded-warn' , email_addr , title ))
205218 elif decisions is not None :
0 commit comments