@@ -87,8 +87,8 @@ sub initialize ($c) {
8787
8888 # Store data
8989 $c -> {defaultPreviewUser } = $ur ;
90- $c -> {defaultFrom } = $ur -> rfc822_mailbox;
91- $c -> {defaultReply } = $ur -> rfc822_mailbox ;
90+ $c -> {from } = $ur -> rfc822_mailbox;
91+ $c -> {from_name } = $ur -> full_name ;
9292 $c -> {defaultSubject } = $c -> stash(' courseID' ) . ' notice' ;
9393 $c -> {merge_file } = $mergefile // ' ' ;
9494
@@ -196,13 +196,11 @@ sub initialize ($c) {
196196 }
197197
198198 # Get inputs
199- my ($from , $replyTo , $ r_text , $subject );
199+ my ($r_text , $subject );
200200 if ($input_source eq ' file' ) {
201201 if ($input_file ) {
202- ($from , $replyTo , $ subject , $r_text ) = $c -> read_input_file(" $emailDirectory /$input_file " );
202+ ($subject , $r_text ) = $c -> read_input_file(" $emailDirectory /$input_file " );
203203 } else {
204- $from = $c -> {defaultFrom };
205- $replyTo = $c -> {defaultReply };
206204 $subject = $c -> {defaultSubject };
207205
208206 # If action is openMessage and no file was found, then 'None' was selected.
@@ -212,16 +210,12 @@ sub initialize ($c) {
212210 $c -> param(' savefilename' , ' default.msg' ) if $c -> param(' savefilename' );
213211 }
214212 }
215- $c -> param(' from' , $from ) if $from ;
216- $c -> param(' replyTo' , $replyTo ) if $replyTo ;
217213 $c -> param(' subject' , $subject ) if $subject ;
218214 $c -> param(' body' , $$r_text ) if $r_text ;
219215 } elsif ($input_source eq ' form' ) {
220216 # read info from the form
221217 # bail if there is no message body
222218
223- $from = $c -> param(' from' );
224- $replyTo = $c -> param(' replyTo' );
225219 $subject = $c -> param(' subject' );
226220 my $body = $c -> param(' body' );
227221 # Sanity check: body must contain non-white space when previewing message.
@@ -233,8 +227,6 @@ sub initialize ($c) {
233227 my $remote_host = $c -> tx-> remote_address || " UNKNOWN" ;
234228
235229 # Store data
236- $c -> {from } = $from ;
237- $c -> {replyTo } = $replyTo ;
238230 $c -> {subject } = $subject ;
239231 $c -> {remote_host } = $remote_host ;
240232 $c -> {r_text } = $r_text ;
@@ -280,8 +272,7 @@ sub initialize ($c) {
280272 $temp_body =~ s /\r\n / \n / g ;
281273 $temp_body = join (
282274 " \n " ,
283- " From: $from " ,
284- " Reply-To: $replyTo " ,
275+ " From: $c ->{from}" ,
285276 " Subject: $subject " ,
286277 " Content-Type: text/plain; charset=UTF-8" ,
287278 " Message:" ,
@@ -315,15 +306,6 @@ sub initialize ($c) {
315306 return ;
316307 }
317308
318- # verify format of Reply-to address (zero or more valid rfc2822/ref5322 addresses)
319- if (defined $c -> {replyTo } and $c -> {replyTo } ne " " ) {
320- my @parsed_replyto_addrs = Email::Address::XS-> parse($c -> {replyTo });
321- unless (@parsed_replyto_addrs > 0) {
322- $c -> addbadmessage($c -> maketext(" Invalid Reply-to address." ));
323- return ;
324- }
325- }
326-
327309 # Check that recipients have been selected.
328310 unless (@{ $c -> {ra_send_to } }) {
329311 $c -> addbadmessage(
@@ -353,7 +335,7 @@ sub initialize ($c) {
353335 text => ${ $c -> {r_text } // \' ' },
354336 merge_data => $c -> {rh_merge_data },
355337 from => $c -> {from },
356- defaultFrom => $c -> {defaultFrom },
338+ from_name => $c -> {from_name },
357339 remote_host => $c -> {remote_host },
358340 } ],
359341 { notes => { courseID => $c -> stash(' courseID' ) } }
@@ -393,10 +375,9 @@ sub print_preview ($c) {
393375 # Note that this escaping is done in the Mojolicious template automatically.
394376 $msg = join (
395377 " " ,
396- " To: " , $c -> {preview_user }-> email_address, " \n " ,
397- " From: " , $c -> {from }, " \n " ,
398- " Reply-To: " , $c -> {replyTo }, " \n " ,
399- " Subject: " , $c -> {subject }, " \n " ,
378+ " To: " , $c -> {preview_user }-> email_address, " \n " ,
379+ " From: " , $c -> {from }, " \n " ,
380+ " Subject: " , $c -> {subject }, " \n " ,
400381 # In a real mails we would UTF-8 encode the message and give the Content-Type header. For the preview which is
401382 # displayed as html, just add the header, but do NOT use Encode::encode("UTF-8",$msg).
402383 " Content-Type: text/plain; charset=UTF-8\n\n " ,
@@ -435,7 +416,7 @@ sub saveMessageFile ($c, $body, $msgFileName) {
435416sub read_input_file ($c , $filePath ) {
436417 my ($text , @text );
437418 my $header = ' ' ;
438- my ( $subject , $from , $replyTo ) ;
419+ my $subject ;
439420
440421 open my $FILE , " <:encoding(UTF-8)" , $filePath
441422 or do { $c -> addbadmessage($c -> maketext(q{ Can't open [_1]} , $filePath )); return };
@@ -445,17 +426,12 @@ sub read_input_file ($c, $filePath) {
445426 $text = join (' ' , <$FILE >);
446427 close $FILE ;
447428
448- $text =~ s / ^\s *// ; # remove initial white space if any.
449- $header =~ / ^From:\s (.*)$ /m ;
450- $from = $1 || $c -> {defaultFrom };
451-
452- $header =~ / ^Reply-To:\s (.*)$ /m ;
453- $replyTo = $1 || $c -> {defaultReply };
429+ $text =~ s / ^\s *// ; # remove initial white space if any.
454430
455431 $header =~ / ^Subject:\s (.*)$ /m ;
456432 $subject = $1 || $c -> {defaultSubject };
457433
458- return ($from , $replyTo , $ subject , \$text );
434+ return ($subject , \$text );
459435}
460436
461437sub get_message_file_names ($c ) {
0 commit comments