#!/usr/bin/perl -w use strict; use Net::SMTP; my $loop = 1; my $from = 'alice@example.com'; my $to = 'bob@example.com'; my $mailhost = '192.0.2.1'; my $eicar = 'W %%% DV # PI# VA l-QE FQ Wz R cU#FpY-NT#Qo#UF4 p %%%% N 0 N D K T d 9J EV JQ 0 F SL %%%% VN ---- UQ_ U5 E$$$Q ####VJEL#U#F%OVElW$SVJVU%y1 UR(VNU LU]ZJ%TEU%hJ^Eg$rSCo= '; my $mail = "To: $to Subject: Foo From: $from MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=\"=-AB=-CD\" Content-Transfer-Encoding: 7bit --=-AB=-CD Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Harmless Text --=-AB=-CD "; for(my $i=1;$i<$loop;$i++) { $mail .= "Content-Type: multipart/alternative; boundary=\"$i=-=-=$i\" Content-Transfer-Encoding: 7bit --$i=-=-=$i "; } $mail .= "Content-Type: application/x-msdos-executable Content-Disposition: attachment; filename=eicar.com; Content-Transfer-Encoding: base64 $eicar "; for(my $i=$loop-1;$i>0;$i--) { $mail .= "--$i=-=-=$i\n"; } $mail .= "--=-AB=-CD\n"; my $smtp = Net::SMTP->new($mailhost); $smtp->hello('foo.example.com'); $smtp->mail($from); $smtp->recipient($to); $smtp->data($mail); print $smtp->code . ' ' . $smtp->message;