Skip to content

Commit 073854d

Browse files
committed
* 20150212 Add %MESSAGEID% token and add Message-Id as a part of the default DATA.
1 parent 859b564 commit 073854d

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,3 +695,5 @@
695695
* 20141202 Fixing a couple of "an [CONSONANT]" doc typos
696696
* 20150128 Handle the case where a server advertises XCLIENT but does not
697697
advertise any supported attributes.
698+
* 20150212 Add %MESSAGEID% token and add Message-Id as a part of the default
699+
DATA.

doc/base.pod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ These options pertain to the contents for the DATA portion of the SMTP transacti
580580

581581
Use argument as the entire contents of DATA, or prompt user if no argument specified. If the argument '-' is provided the data will be read from STDIN. If any other argument is provided and it represents the name of an open-able file, the contents of the file will be used. Any other argument will be itself for the DATA contents.
582582

583-
The value can be on one single line, with \n (ascii 0x5c, 0x6e) representing where line breaks should be placed. Leading dots will be quoted. Closing dot is not required but is allowed. The default value for this option is "Date: %DATE%\nTo: %TO_ADDRESS%\nFrom: %FROM_ADDRESS%\nSubject: test %DATE%\nX-Mailer: swaks v$p_version jetmore.org/john/code/swaks/\n%NEW_HEADERS%\n%BODY%\n".
583+
The value can be on one single line, with \n (ascii 0x5c, 0x6e) representing where line breaks should be placed. Leading dots will be quoted. Closing dot is not required but is allowed. The default value for this option is "Date: %DATE%\nTo: %TO_ADDRESS%\nFrom: %FROM_ADDRESS%\nSubject: test %DATE%\nMessage-Id: <%MESSAGEID%>\nX-Mailer: swaks v$p_version jetmore.org/john/code/swaks/\n%NEW_HEADERS%\n%BODY%\n".
584584

585585
Very basic token parsing is performed on the DATA portion. See --use-old-data-tokens for details about the single-character tokens marked as deprecated. The following table shows the recognized tokens and their replacement values:
586586

@@ -598,6 +598,10 @@ Replaced with the envelope-recipient(s). Replaces the deprecated %T token.
598598

599599
Replaced with the current time in a format suitable for inclusion in the Date: header. Note this attempts to use the standard module Time::Local for timezone calculations. If this module is unavailable the date string will be in GMT. Replaces the deprecated %D token.
600600

601+
=item %MESSAGEID%
602+
603+
Replaced with the a message ID string suitable for use in a Message-Id header. The value for this token will remain consistent for the life of the process.
604+
601605
=item %NEW_HEADERS%
602606

603607
Replaced with the contents of the --add-header option. If --add-header is not specified this token is simply removed. Replaces the deprecated %H token.

swaks

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,17 @@ sub interact {
12311231
return($response);
12321232
}
12331233

1234+
sub get_messageid {
1235+
if (!$G::message_id) {
1236+
my @time = localtime();
1237+
$G::message_id = sprintf("%04d%02d%02d%02d%02d%02d.%06d\@%s",
1238+
$time[5]+1900, $time[4]+1, $time[3], $time[2], $time[1], $time[0],
1239+
$$, get_hostname());
1240+
}
1241+
1242+
return($G::message_id);
1243+
}
1244+
12341245
sub get_hostname {
12351246
# in some cases hostname returns value but gethostbyname doesn't.
12361247
return("") if (!avail("hostname"));
@@ -2198,6 +2209,7 @@ sub process_args {
21982209
$n{data} = $o->{mail_data} || interact("Data: ", '^.*$');
21992210
}
22002211
$n{data} ||= 'Date: %DATE%\nTo: %TO_ADDRESS%\nFrom: %FROM_ADDRESS%\nSubject: test %DATE%\n' .
2212+
"Message-Id: <%MESSAGEID%>\n" .
22012213
"X-Mailer: swaks v$p_version jetmore.org/john/code/swaks/".'\n' .
22022214
($bound ? 'MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary="'.$bound.'"\n' : '') .
22032215
'%NEW_HEADERS%' . # newline will be added in replacement if it exists
@@ -2235,6 +2247,7 @@ sub process_args {
22352247
$n{data} =~ s/%FROM_ADDRESS%/$n{from}/g;
22362248
$n{data} =~ s/%F/$n{from}/g if ($O{use_old_data_tokens});
22372249
$n{data} =~ s/%TO_ADDRESS%/$n{to}/g;
2250+
$n{data} =~ s/%MESSAGEID%/get_messageid()/ge;
22382251
$n{data} =~ s/%T/$n{to}/g if ($O{use_old_data_tokens});
22392252
{ # braces are to limit scope of $date_string
22402253
my $date_string = get_date_string();

0 commit comments

Comments
 (0)