Alister West

home is where your code is ...

Send Email

Lots of ways and reasons to send email. Here are some standalone bits.

Send email with virus attachment

Used to test Clam. I had problems with EICAR site.

!/usr/bin/env perl
#
# Send a harmless virus somewhere (for testing virus protection)
# 
# author: Alister West 
# virus from http://www.aleph-tec.com/eicar:
# X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
#
use strict;
use warnings;
use feature qw/say/;

use Email::MIME;
use Email::MIME::Creator;
use Email::Sender::Simple qw/sendmail/;
use MIME::Base64 qw/decode_base64/;

my $to = 'ronnie@ronnietest.gossamer-host.com';
my $email = Email::MIME->create(
    header => [
        From => 'alister@gt.net',
        To => $to,
        Subject => 'Sharks ahoy!',
    ],
    parts => [
        Email::MIME->create(
            attributes => {
                filename     => 'eicar_com.zip',
                content_type => "application/zip",
                encoding     => "quoted-printable",
                name         => "eicar_com.zip",
            },
            body => decode_base64( "UEsDBAoAAAAAAOCYuCg8z1FoRAAAAEQAAAAJAAAAZWljYXIuY29tWDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCpQSwECFAAKAAAAAADgmLgoPM9RaEQAAABEAAAACQAAAAAAAAABACAA/4EAAAAAZWljYXIuY29tUEsFBgAAAAABAAEANwAAAGsAAAAAAA=="),
        ),
        Email::MIME->create(
            attributes => { content_type => "text/plain", charset => "US-ASCII", },
            body => "Watchout for the attachement!",
        ),
    ]
);

say "Sending email to $to with virus attached.";
sendmail($email);
By Alister West