For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > for send an email part II









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author for send an email part II
Rafael Morales

2006-01-10, 4:02 am

Well I have done this code, but the messages arrive in white :(, anybody co=
uld help me with this please ???.
Note: I do not know the list of users for that reason I need multipart.

Regards

#!/usr/bin/perl
use strict;
use warnings;

my $msg_html =3D "message.html";
my $msg_txt =3D "message.txt";
open (MAIL, "|/usr/sbin/sendmail -t") || die "No hay acceso al binario =
sendmail\n";
open (HTML, "$msg_html") || die "Html no existe\t$!\n";
open (TXT, "$msg_txt") || die "Txt no existe\t$!\n";
my @html =3D <HTML>;
my @txt =3D <TXT>;

my $boundary =3D "=3D_" . time();
$boundary =3D '"' . '----' . $boundary . '"';
my $To =3D 'user@domain.net';
my $FromMail =3D 'sender@sender.domain';
my $FromName =3D 'Sender Name';
my $Bcc =3D 'other@domain.com';
my $Subject =3D "Testing multipart";

print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: multipart/alternative; boundary=3D $boundary\=
n";;
print MAIL "From: $FromName<$FromMail>\n";
print MAIL "To: $To\n";
print MAIL "Cc: $Bcc\n";
print MAIL "Subject: $Subject\n";

my $correo =3D <<"MAIL_BODY";
$boundary
Content-Type: text/plain;
charset=3D "iso-8859-1"
Content-Transfer-Encoding: 8bit
@txt

$boundary
Content-Type: text/html;
charset=3D "iso-8859-1"
Content-Transfer-Encoding: quoted-printable
@html
$boundary
MAIL_BODY

print MAIL "$correo\n";


--=20
________________________________________
_______
Get your free email from http://mymail.bsdmail.com
Dr.Ruud

2006-01-10, 4:02 am

Rafael Morales:

> Well I have done this code, but the messages arrive in white


There should be at least one empty line between header and body,
so add a "\n" somewhere.

--
Affijn, Ruud

"Gewoon is een tijger."

Rafael Morales

2006-01-10, 4:02 am

I have added the "\n", however the mails are still arriving empty :(

I did

...
print MAIL "Subject: $Subject";
print MAIL "\n\n"; <------ This line I have added

my $correo =3D <<"MAIL_BODY";

$boundary

... Text here ..

$boundary

MAIL_BODY


=20


----- Original Message -----
From: "Dr.Ruud" <rvtol+news@isolution.nl>
To: beginners@perl.org
Subject: Re: for send an email part II
Date: Thu, 29 Dec 2005 22:07:52 +0100

>=20
> Rafael Morales:
>=20
>=20
> There should be at least one empty line between header and body,
> so add a "\n" somewhere.
>=20
> --
> Affijn, Ruud
>=20
> "Gewoon is een tijger."
>=20
>=20
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>



--=20
________________________________________
_______
Get your free email from http://mymail.bsdmail.com
Rafael Morales

2006-01-10, 4:02 am

Yes, and I did that, my first choice was to use Mail::Sendmail, however it =
does not work fine with Yahoo, because the mails arrive empty. But I will p=
lay with the choices you have given me.

Thanks and regards !!!=20=20


----- Original Message -----
From: "Jenda Krynicky" <Jenda@Krynicky.cz>
To: "Rafael Morales" <daredevil@bsdmail.com>, beginners@perl.org
Subject: Re: for send an email part II
Date: Fri, 30 Dec 2005 00:21:52 +0100

>=20
> From: "Rafael Morales" <daredevil@bsdmail.com>
>=20
> Please do not reinvent the wheel. Generating MIME encoded emails is
> not as trivial as it may seem at the first glance. Been there, done
> that! Use one of the several modules you can already find on CPAN:
>=20
> MIME::Lite, Mail::Sender, MIME::Entity, ...
>=20
> Jenda
> =3D=3D=3D=3D=3D Jenda@Krynicky.cz =3D=3D=3D http://Jenda.Krynicky.cz =3D=

=3D=3D=3D=3D
> When it comes to wine, women and song, wizards are allowed
> to get drunk and croon as much as they like.
> -- Terry Pratchett in Sourcery



--=20
________________________________________
_______
Get your free email from http://mymail.bsdmail.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com