Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Emailing from Perl on Windows platforms

Posted by admin (Graham Ellis), 11 February 2006
Perl doesn't include built-in emailing functions.  On Unix or Linux boxes, I've always put in calls to the local sendmail program and that works just fine, but there's no sendmail on Microsoft boxes ...

Alternative - use a CPAN module (or rather a module that you can download with ppm);   here's the "engine" of a program that I wrote a s demo in the last couple of days:

use Mail::Sendmail;

%mail = (To => '',
From => 'Graham Ellis <>',
Message => "First line\nSecond line\netc\n",
Subject => "Perl email from Windows",
Reply-to => '',
smtp => '');

$aok = sendmail(%mail);

See Complete example and further documentation

Posted by aparks (aparks), 25 May 2006
You might also use MIME::Lite (also up on CPAN) if you need to attach files to your email. We use this for firing off server logs to a central email account (which we then ignore like all good sysadmins )

use MIME::Lite;

my($mailServer) = '';
my($mailFrom)   = '';
my($mailTo)      = '';
my($realName)   = "Adrian";
my($subject)    = "Subject of message";
my($body)      = "Body of message"
my ($file)      = "c:\\temp\\file.fil";

my $msg = MIME::Lite->new(

     To => "$mailTo",

     $msg->attach(      Type      =>'TEXT',
                 Data      =>"$body");
     $msg->attach(      Type      =>'TEXT',
                       Path      =>"$file",
                       Disposition => 'attachment');

MIME::Lite->send('smtp', "$mailServer",Timeout=>60);


Wow - finally I've contributed something back to OpenTalk (well hopefully anyway). I've been feeling guilty about all the unrequited help I've had from here over the years...

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho