@@ -87,8 +87,8 @@ sub initialize ($c) {
87
87
88
88
# Store data
89
89
$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 ;
92
92
$c -> {defaultSubject } = $c -> stash(' courseID' ) . ' notice' ;
93
93
$c -> {merge_file } = $mergefile // ' ' ;
94
94
@@ -196,13 +196,11 @@ sub initialize ($c) {
196
196
}
197
197
198
198
# Get inputs
199
- my ($from , $replyTo , $ r_text , $subject );
199
+ my ($r_text , $subject );
200
200
if ($input_source eq ' file' ) {
201
201
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 " );
203
203
} else {
204
- $from = $c -> {defaultFrom };
205
- $replyTo = $c -> {defaultReply };
206
204
$subject = $c -> {defaultSubject };
207
205
208
206
# If action is openMessage and no file was found, then 'None' was selected.
@@ -212,16 +210,12 @@ sub initialize ($c) {
212
210
$c -> param(' savefilename' , ' default.msg' ) if $c -> param(' savefilename' );
213
211
}
214
212
}
215
- $c -> param(' from' , $from ) if $from ;
216
- $c -> param(' replyTo' , $replyTo ) if $replyTo ;
217
213
$c -> param(' subject' , $subject ) if $subject ;
218
214
$c -> param(' body' , $$r_text ) if $r_text ;
219
215
} elsif ($input_source eq ' form' ) {
220
216
# read info from the form
221
217
# bail if there is no message body
222
218
223
- $from = $c -> param(' from' );
224
- $replyTo = $c -> param(' replyTo' );
225
219
$subject = $c -> param(' subject' );
226
220
my $body = $c -> param(' body' );
227
221
# Sanity check: body must contain non-white space when previewing message.
@@ -233,8 +227,6 @@ sub initialize ($c) {
233
227
my $remote_host = $c -> tx-> remote_address || " UNKNOWN" ;
234
228
235
229
# Store data
236
- $c -> {from } = $from ;
237
- $c -> {replyTo } = $replyTo ;
238
230
$c -> {subject } = $subject ;
239
231
$c -> {remote_host } = $remote_host ;
240
232
$c -> {r_text } = $r_text ;
@@ -280,8 +272,7 @@ sub initialize ($c) {
280
272
$temp_body =~ s /\r\n / \n / g ;
281
273
$temp_body = join (
282
274
" \n " ,
283
- " From: $from " ,
284
- " Reply-To: $replyTo " ,
275
+ " From: $c ->{from}" ,
285
276
" Subject: $subject " ,
286
277
" Content-Type: text/plain; charset=UTF-8" ,
287
278
" Message:" ,
@@ -315,15 +306,6 @@ sub initialize ($c) {
315
306
return ;
316
307
}
317
308
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
-
327
309
# Check that recipients have been selected.
328
310
unless (@{ $c -> {ra_send_to } }) {
329
311
$c -> addbadmessage(
@@ -353,7 +335,7 @@ sub initialize ($c) {
353
335
text => ${ $c -> {r_text } // \' ' },
354
336
merge_data => $c -> {rh_merge_data },
355
337
from => $c -> {from },
356
- defaultFrom => $c -> {defaultFrom },
338
+ from_name => $c -> {from_name },
357
339
remote_host => $c -> {remote_host },
358
340
} ],
359
341
{ notes => { courseID => $c -> stash(' courseID' ) } }
@@ -393,10 +375,9 @@ sub print_preview ($c) {
393
375
# Note that this escaping is done in the Mojolicious template automatically.
394
376
$msg = join (
395
377
" " ,
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 " ,
400
381
# In a real mails we would UTF-8 encode the message and give the Content-Type header. For the preview which is
401
382
# displayed as html, just add the header, but do NOT use Encode::encode("UTF-8",$msg).
402
383
" Content-Type: text/plain; charset=UTF-8\n\n " ,
@@ -435,7 +416,7 @@ sub saveMessageFile ($c, $body, $msgFileName) {
435
416
sub read_input_file ($c , $filePath ) {
436
417
my ($text , @text );
437
418
my $header = ' ' ;
438
- my ( $subject , $from , $replyTo ) ;
419
+ my $subject ;
439
420
440
421
open my $FILE , " <:encoding(UTF-8)" , $filePath
441
422
or do { $c -> addbadmessage($c -> maketext(q{ Can't open [_1]} , $filePath )); return };
@@ -445,17 +426,12 @@ sub read_input_file ($c, $filePath) {
445
426
$text = join (' ' , <$FILE >);
446
427
close $FILE ;
447
428
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.
454
430
455
431
$header =~ / ^Subject:\s (.*)$ /m ;
456
432
$subject = $1 || $c -> {defaultSubject };
457
433
458
- return ($from , $replyTo , $ subject , \$text );
434
+ return ($subject , \$text );
459
435
}
460
436
461
437
sub get_message_file_names ($c ) {
0 commit comments