+
Skip to content

Set attachments content ID #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions RELEASE/doc/ref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,14 @@ DATA OPTIONS
this option, it causes no filename information to be included for
the next MIME part, even if Swaks could generate it from the local
file name. (Arg-Optional)

--attach-id [<name>]
This option sets the Content-ID that will be included in the MIME part
created for the next "--attach" option. This Content-ID can then be referenced
in the HTML body using cid:contentID. If no argument is set for
this option, it causes no Content-ID information to be included for
the next MIME part, even if Swaks could generate it from the local
file name. (Arg-Optional)

-ah, --add-header <header>
This option allows headers to be added to the DATA. If
Expand Down
16 changes: 16 additions & 0 deletions swaks
Original file line number Diff line number Diff line change
Expand Up @@ -2300,6 +2300,10 @@ sub get_option_struct {
cfgs => OP_ARG_REQ,
okey => 'attach_type', akey => 'attach_accum', type => 'list', },
# A file to attach
{ opts => ['attach-id'], suffix => ':s',
cfgs => OP_ARG_REQ,
okey => 'attach_id', akey => 'attach_accum', type => 'list', },
# A file to attach
{ opts => ['attach'], suffix => ':s',
cfgs => OP_ARG_REQ|OP_FROM_FILE,
okey => 'attach_attach', akey => 'attach_accum', type => 'list', },
Expand Down Expand Up @@ -3300,6 +3304,7 @@ sub process_args {
# first text/plain part
my $mime_type = '%SWAKS_DEFAULT_MIMETYTPE%';
my $next_name = undef();
my $next_id = undef();
my %parts = ( body => [], rest => [] );
$bound = "----=_MIME_BOUNDARY_000_$$";
foreach my $part (@$attach_accum) {
Expand All @@ -3309,12 +3314,16 @@ sub process_args {
elsif ($part eq 'attach_name') {
$next_name = get_arg($part, $o);
}
elsif ($part eq 'attach_id') {
$next_id = get_arg($part, $o);
}
elsif ($part eq 'attach_body') {
if ($mime_type eq '%SWAKS_DEFAULT_MIMETYTPE%') {
$mime_type = 'text/plain';
}
push(@{$parts{body}}, { body => get_arg($part, $o), type => $mime_type });
$next_name = undef(); # can't set filename for body, unset next_name so random attachment doesn't get it
$next_id = undef(); # can't set id for body
$mime_type = '%SWAKS_DEFAULT_MIMETYTPE%'; # after each body, reset the default mime type
}
elsif ($part eq 'attach_attach') {
Expand All @@ -3334,6 +3343,10 @@ sub process_args {
$tpart->{name} =~ s|^.*/([^/]+)$|$1|;
}
}
if (defined($next_id)) {
$tpart->{id} = $next_id;
$next_id = undef();
}
push(@{$parts{rest}}, $tpart);
} else {
ptrans(12, "Error processing attach args, unknown type $part when processing attachment options");
Expand Down Expand Up @@ -3890,6 +3903,9 @@ sub encode_mime_part {
$text .= "Content-Disposition: attachment\n";
}
}
if ($part->{id}) {
$text .= "Content-ID: $part->{id}\n"
}
$text .= "Content-Transfer-Encoding: BASE64\n"
. "\n" . eb64($part->{body}, "\n") . "\n";
}
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载