Hi! I'm posting a somewhat of a solution to a problem which I needed to solve here. Hope some one will find it useful. What I needed the database to do was to send out mails in both html and plain text format without sending out two mails to the same user. Basically what I was achieving here is like some of the newletters which you receive, some of them in the same message contains both the html veersionas well as the plain-text version. Depending on how you set up your email program, the mail when receieved by you will either show the html version if not the plain-text version.
I attempted to change the Mailer.pm module given in the links2 package but to no avail I search ariund and found another module which will do exatcly what I needed. The name of the module is call MIME::Lite available from CPAN. However I could not understand how to incorporate this module with the exisiting module, thus I bssically forgo the existing module and use MIME::Lite instead. What you need to do if you have shell access, is to install the module on your server. However, I was informed as well that if you can't have shell access, all you need to do is place the file Lite.pm into a directory say like the links2 directory and then reference it in the links scripts like so:
use lib "/mydisk/myusername/lib";
use MIME::Lite;
then replace the code that would set up the mailing function in the existing script with these:
MIME::Lite->send('smtp', "smtp.domain.com", Timeout=>60);
$mail = MIME::Lite->new(
From =>$from,
To =>$to,
Subject =>$subject,
Type =>'multipart/alternative'
);
$mail->attach(Type =>'TEXT',
Data =>$msgtxt
);
$mail->attach(Type =>'text/html',
Data =>$msg
);
$mail->send;
If you do not use smtp, replace it with
MIME::Lite->send("sendmail", "/usr/lib/sendmail -t -oi -oem");
Then all you have to do is to use
$msg = qq| print all your html codes including all the necessary html headers here|;
$msgtxt = qq| print all your plain text here|;
I think that's it. I tried it out and it works. I have also attach the Lite.pm file. If anyone knows how to incorporate this module into the exisiting Mailer.pm module, please tell me. I would very much appreciate learning new ways.
Thank you.
Julian
I attempted to change the Mailer.pm module given in the links2 package but to no avail I search ariund and found another module which will do exatcly what I needed. The name of the module is call MIME::Lite available from CPAN. However I could not understand how to incorporate this module with the exisiting module, thus I bssically forgo the existing module and use MIME::Lite instead. What you need to do if you have shell access, is to install the module on your server. However, I was informed as well that if you can't have shell access, all you need to do is place the file Lite.pm into a directory say like the links2 directory and then reference it in the links scripts like so:
use lib "/mydisk/myusername/lib";
use MIME::Lite;
then replace the code that would set up the mailing function in the existing script with these:
MIME::Lite->send('smtp', "smtp.domain.com", Timeout=>60);
$mail = MIME::Lite->new(
From =>$from,
To =>$to,
Subject =>$subject,
Type =>'multipart/alternative'
);
$mail->attach(Type =>'TEXT',
Data =>$msgtxt
);
$mail->attach(Type =>'text/html',
Data =>$msg
);
$mail->send;
If you do not use smtp, replace it with
MIME::Lite->send("sendmail", "/usr/lib/sendmail -t -oi -oem");
Then all you have to do is to use
$msg = qq| print all your html codes including all the necessary html headers here|;
$msgtxt = qq| print all your plain text here|;
I think that's it. I tried it out and it works. I have also attach the Lite.pm file. If anyone knows how to incorporate this module into the exisiting Mailer.pm module, please tell me. I would very much appreciate learning new ways.
Thank you.
Julian