PDA

View Full Version : Perl script with php


ravin
05-14-2008, 10:42 AM
Hello,

I never used perl before but it seems like I need it!

Im using Apache under win32 with perl?

Here is some info from my phpinfo()

PCRE (Perl Compatible Regular Expressions) Support enabled
PCRE Library Version 6.7 04-Jul-2006

Loaded modules : mod_mime

mime_magic support : off


I also have C:\Program Files\xampp\perl\bin\perl.exe


Here is the code I found,

#!/usr/bin/perl -w

use strict;
use MIME::Lite;

my $msg = MIME::Lite->new(
From =>'edwin@mavetju.org',
To =>'administrator@example.org',
Subject =>'Join me!',
Type =>'multipart/alternative'
);
$msg->attr(
'content-class' => 'urn:content-classes:calendarmessage'
);
$msg->attach(
Type => "TEXT",
Data => "foo bar quux"
);

my $part = MIME::Lite->new(
Type => "text/calendar; method=REQUEST; name=\"subject.ics\"",
Filename => "subject.ics",
Path => "subject.ics",
Encoding => "8bit",
);
$part->scrub(['date', 'x-mailer', 'mime-version']);
$part->attr(
'content-class' => 'urn:content-classes:calendarmessage',
'content-description' => "subject.ics",
);
$part->replace(
'content-disposition' => "",
);
$msg->attach($part);

$msg->send;

It is a code for sending out a Microsoft Outlook Calender invitation.

How can I use this from a website? And how is it written in a php file? I´ll use different variables each time, from mysql database.

Any ideas? :)

FishMonger
05-14-2008, 06:22 PM
Please use the 'code' tags when posting code so that it retains the formatting/indentation.

First of all, have you tested this script and does it successfully send the email?

How can I use this from a website?Without having more details on what you're doing in your website, I can't give exact instructions. In general, your web page would either have a form that points to this script i.e., the form's method attribute is set to this script. Or, you have a simple html link that the user clicks on.

how is it written in a php file?Are you asking how to translate that perl script to php or how to have your php script call that perl script?