Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How do I send text / html Mail with GT::Mail

Quote Reply
How do I send text / html Mail with GT::Mail
Hi,

I am trying to find out how to do the above.
I found:
Code:
use MIME::Lite;

my $from = 'I Programmer <sender@sender.com>';
my $subject = 'I am a Perl programmer';
my $to = 'rec@rec.com';
my $html = q|
<a href="http://www.link.info/">
I-Programmer
</a>
|;

my $text = q|
We can only have text links here
http://www.link.info/
|;

my $msg = MIME::Lite->new(
From => $from,
To => $to,
Type => 'multipart/alternative',
Subject => $subject,
);

my $att_text = MIME::Lite->new(
Type => 'text',
Data => $text,
Encoding => 'quoted-printable',
);
$att_text->attr('content-type'
=> 'text/plain; charset=UTF-8');
$msg->attach($att_text);

my $att_html = MIME::Lite->new(
Type => 'text',
Data => $html,
Encoding => 'quoted-printable',
);
$att_html->attr('content-type'
=> 'text/html; charset=UTF-8');
$msg->attach($att_html);

$msg->send;
And thought I could do something like:
Code:
my $html_mail = Links::send_email('mail_html.eml',$results, { get_body => 1 });
my $txt_mail = Links::send_email('mail_txt.eml',$results, { get_body => 1 });
use GT::Mail;
my $send = new GT::Mail (
type => 'multipart/alternative',
to => 'rec@rec.com',
from => 'sender@sender.com',
subject => "subject",
msg => '',
debug => 0,
sendmail => $CFG->{db_mail_path},
);
$send->attach(
type => 'text/plain; charset=UTF-8',
body_data => $txt_mail
);
$send->attach(
type => 'text/html; charset=UTF-8',
body_data => $html_mail
);
$send->send() or die "Error: $GT::Mail::error";
But I think I am a little off track here.

Thanks for any help

n||i||k||o
Subject Author Views Date
Thread How do I send text / html Mail with GT::Mail el noe 5153 Jun 27, 2016, 7:33 AM
Thread Re: [el noe] How do I send text / html Mail with GT::Mail
Andy 4992 Jun 27, 2016, 8:44 AM
Thread Re: [Andy] How do I send text / html Mail with GT::Mail
el noe 4959 Jun 27, 2016, 11:07 AM
Post Re: [el noe] How do I send text / html Mail with GT::Mail
Andy 4951 Jun 27, 2016, 12:01 PM