+sub _add_body_start {
+ my $body_start = <<"BODY_START";
+This is a multi-part message in MIME format.
+--$mime_boundary
+Content-Type: text/plain; format=fixed
+Content-Transfer-Encoding: 8bit
+
+BODY_START
+ return $body_start;
+}
+
+sub _add_attachments {
+ my $attach = '';
+ for my $attachment (split /\s*,\s*/, $attachments) {
+ my $attach_file = basename($attachment);
+ $attach .= <<"ATTACHMENT";
+
+--$mime_boundary
+Content-Type: text/x-patch; name="$attach_file"
+Content-Transfer-Encoding: 8bit
+Content-Disposition: attachment; filename="$attach_file"
+
+ATTACHMENT
+
+ open my $attach_fh, '<:raw', $attachment
+ or die "Couldn't open attachment '$attachment': $!\n";
+ while (<$attach_fh>) { $attach .= $_; }
+ close($attach_fh) or die "Error closing attachment '$attachment': $!";
+ }
+
+ $attach .= "\n--$mime_boundary--\n";
+ return $attach;
+}
+