Training, Open Source computer languages

This is page http://www.wellho.net/forum/Perl-Programming/Emailing ... forms.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - 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:

Code:
use Mail::Sendmail;

%mail = (To => 'graham@sheepbingo.co.uk',
From => 'Graham Ellis <graham@wellho.net>',
Message => "First line\nSecond line\netc\n",
Subject => "Perl email from Windows",
Reply-to => 'graham@wellho.net',
smtp => 'lightning.he.net');

$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 )

Code:
use MIME::Lite;

my($mailServer) = 'smtp.company.com';
my($mailFrom)   = 'adrian@mycompany.com';
my($mailTo)      = 'someoneelse@mycompany.com';
my($realName)   = "Adrian";
my($subject)    = "Subject of message";
my($body)      = "Body of message"
my ($file)      = "c:\\temp\\file.fil";

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

     From=>"$mailFrom",
     To => "$mailTo",
     Subject=>"$subject",
     Type=>'multipart/mixed');

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


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

$msg->send;


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 www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

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