[31734] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2997 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 21 14:09:28 2010

Date: Mon, 21 Jun 2010 11:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 21 Jun 2010     Volume: 11 Number: 2997

Today's topics:
    Re: FAQ 7.11 How do I create a class? <apeiron@isuckatdomains.net.invalid>
    Re: FAQ 9.15 How do I parse a mail header? <apeiron@isuckatdomains.net.invalid>
    Re: FAQ 9.22 How do I read mail? <apeiron@isuckatdomains.net.invalid>
        file modified thinggummy and time <robin1@cnsp.com>
    Re: file modified thinggummy and time <uri@StemSystems.com>
    Re: file modified thinggummy and time <groundXaero@gmail.com>
        How to submit utility - not module - to CPAN <Steve.Roscio@hp.com>
    Re: Newbie: Where to get support for basic Perl problem <marc.girod@gmail.com>
    Re: Newbie: Where to get support for basic Perl problem <ben@morrow.me.uk>
    Re: problem sending email using MIME::Lite from gmail's <hjp-usenet2@hjp.at>
    Re: problem sending email using MIME::Lite from gmail's <hjp-usenet2@hjp.at>
    Re: problem sending email using MIME::Lite from gmail's <r.ted.byers@gmail.com>
    Re: problem sending email using MIME::Lite from gmail's <r.ted.byers@gmail.com>
    Re: problem sending email using MIME::Lite from gmail's <r.ted.byers@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 20 Jun 2010 12:00:22 +0000 (UTC)
From: Chris Nehren <apeiron@isuckatdomains.net.invalid>
Subject: Re: FAQ 7.11 How do I create a class?
Message-Id: <hvkvsm$ps8$1@news.eternal-september.org>

On 2010-06-20, PerlFAQ Server scribbled these curious markings:
> 7.11: How do I create a class?

This entry really should cover Moose, which has been gaining traction in
the Perl community for the better part of a decade now. I'm installing
it on my netbook presently, as a matter of fact.

-- 
Thanks and best regards,
Chris Nehren
Unless noted, all content I post is CC-BY-SA.


------------------------------

Date: Mon, 21 Jun 2010 10:16:34 +0000 (UTC)
From: Chris Nehren <apeiron@isuckatdomains.net.invalid>
Subject: Re: FAQ 9.15 How do I parse a mail header?
Message-Id: <hvne62$tdf$2@news.eternal-september.org>

On 2010-06-21, PerlFAQ Server scribbled these curious markings:
> 9.15: How do I parse a mail header?

Another *CRINGE*. Email::Simple.

-- 
Thanks and best regards,
Chris Nehren
Unless noted, all content I post is CC-BY-SA.


------------------------------

Date: Mon, 21 Jun 2010 10:16:11 +0000 (UTC)
From: Chris Nehren <apeiron@isuckatdomains.net.invalid>
Subject: Re: FAQ 9.22 How do I read mail?
Message-Id: <hvne5b$tdf$1@news.eternal-september.org>

On 2010-06-20, PerlFAQ Server scribbled these curious markings:
> 9.22: How do I read mail?

*CRINGE*

*twitch*

At the very *least*, Email::Folder, please.

-- 
Thanks and best regards,
Chris Nehren
Unless noted, all content I post is CC-BY-SA.


------------------------------

Date: Sat, 19 Jun 2010 23:08:43 -0700 (PDT)
From: Robin <robin1@cnsp.com>
Subject: file modified thinggummy and time
Message-Id: <1f9775ea-b9f7-4317-8eb9-90db14d07dfc@i28g2000yqa.googlegroups.com>

How, hypothetically, would I check a file to see if it was modified 5
minutes from the moment I checked it? Is it the stat command...sorry
to ask you, I couldn't figure it out.
Thanks,
and regards,
-Robin


------------------------------

Date: Sun, 20 Jun 2010 02:38:37 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: file modified thinggummy and time
Message-Id: <87zkyqxl76.fsf@quad.sysarch.com>

>>>>> "R" == Robin  <robin1@cnsp.com> writes:

  R> How, hypothetically, would I check a file to see if it was modified 5
  R> minutes from the moment I checked it? Is it the stat command...sorry
  R> to ask you, I couldn't figure it out.

crazy spammer asking for help. not much chance of getting it.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Sun, 20 Jun 2010 12:17:54 +0530
From: Xaero <groundXaero@gmail.com>
Subject: Re: file modified thinggummy and time
Message-Id: <20100620121754.25a7f8d8.groundXaero@gmail.com>

yeah stat or "file test operators" (perfunc)

Regards.

----------------------------------
On Sat, 19 Jun 2010 23:08:43 -0700 (PDT)
Robin <robin1@cnsp.com> wrote:

> How, hypothetically, would I check a file to see if it was modified 5
> minutes from the moment I checked it? Is it the stat command...sorry
> to ask you, I couldn't figure it out.
> Thanks,
> and regards,
> -Robin


-- 
Xaero <groundXaero@gmail.com>

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---


------------------------------

Date: Mon, 21 Jun 2010 09:34:45 -0600
From: Steve Roscio <Steve.Roscio@hp.com>
Subject: How to submit utility - not module - to CPAN
Message-Id: <hvnvlr$jhk$1@usenet01.boi.hp.com>

G'day -

I'd like to submit a small utility to CPAN (like those found in 
perlutil)  It's not a module.  How do I package it for upload?
Do I make a dummy module for it, holding just a shebang and the POD?

Thanx,
- Steve


------------------------------

Date: Sat, 19 Jun 2010 06:32:11 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: Newbie: Where to get support for basic Perl problem?
Message-Id: <9fed5ad7-c361-4c37-9968-b85efeab2347@x27g2000yqb.googlegroups.com>

On Jun 19, 1:09=A0pm, Clive <clive_l...@yahoo.com> wrote:

> When I look in
> /mnt/freenasmount/Slimnas/squeezebox/CPAN/UUID library on the FreeNAS
> server, then =93module=94 Tiny.pm IS in there

/mnt/freenasmount/Slimnas/squeezebox/CPAN/UUID is a directory, not a
library.
The module Tiny.pm is there, but obviously this is not where it is
being looked for.

It is being looked for in the directory list specified as @INC.
For perl to find UUID::Tiny.pm, @INC should contain:
/mnt/freenasmount/Slimnas/squeezebox/CPAN

Obviously, it does not.
So, the module may have been incorrectly installed (one answer you
already got).
You might install it correctly.
Or you might try to run your script with:

perl -I/mnt/freenasmount/Slimnas/squeezebox/CPAN <your_script>

This might get you past the first error.

Marc


------------------------------

Date: Sat, 19 Jun 2010 14:52:00 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Newbie: Where to get support for basic Perl problem?
Message-Id: <0luue7-jac2.ln1@osiris.mauzo.dyndns.org>


Quoth Clive <clive_long@yahoo.com>:
> {quote=

Please quote in a more standard manner.

> {quote=
> I dunno what that Tiny.pm might be, but it is not the one that is
> being looked for.
> It first looks for a *directory* named UUID under one of the
> listed @INC dirs, then it looks for a file named Tiny.pm
> inside of that UUID/ directory. }
> 
> Yes, I understand.
> The INC statement has the following references
> 
> [10-06-19 09:40:57.7131] main::init (400) Warning: Can't locate UUID/
> Tiny.pm in @INC
> (@INC contains:
> << Snipped lots of CPAN libraries >>
> /mnt/freenasmount/Slimnas/squeezebox/CPAN
> /mnt/freenasmount/Slimnas/squeezebox
> /usr/local/lib/perl5/5.8.9/BSDPAN
> << snip /usr/local libraries
>  at /mnt/freenasmount/Slimnas/squeezebox/slimserver.pl line 400.
> 
> When I look in
> /mnt/freenasmount/Slimnas/squeezebox/CPAN/UUID library on the FreeNAS
> server, then 'module' Tiny.pm IS in there - so why isn't it being
> found and loaded? (I'm not sure if 'found' 'Loaded' are the correct
> Perl terms)

Is there a permissions issue of some sort? 

Ben



------------------------------

Date: Sat, 19 Jun 2010 15:56:42 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <slrni1pj4r.a5j.hjp-usenet2@hrunkner.hjp.at>

On 2010-06-18 22:22, Ted Byers <r.ted.byers@gmail.com> wrote:
> While the html displays OK, the top haif of it is repeated at the end.
> Equally badly, the link between the jpg file (containing the logo) and
> the img tag in the html is broken.
>
> The first few lines, showing the package I am using are:
[...]
> use Email::MIME::Creator;
[...]
> my $html_part = Email::MIME->create(
>           attributes => {
>              content_type => "text/html",
>           },
>           body => "$html_template",
> );
> my $image_part = Email::MIME->create(
>           attributes => {
>              content_type => "image/jpg",
>              name         => "logo.jpg",
>           },
>           body => io( "template.files/image002.jpg" )->all,
> );
> my @parts = ($html_part,$image_part);
> my $message = Email::MIME->create(
>       header => [
>           From => 'connie@capitalbusinessservices.net',
>           To   => 'r.ted.byers@gmail.com',
> 	  Subject => $subject,
>       ],
>       parts => \@parts,
> );
[...]
> It could hardly be simpler.
>
> The img tag is:
>
><img width=634 height=95 src="logo.jpg" v:shapes="_x0000_i1025">

That doesn't work. You cannot use a relative URL like "logo.jpg" in an
email. You can either use an http: URL (but many mailers won't resolve
them by default for privacy reasons (google "web bugs" for details)) or
a cid: URL to refer to an image within the email (this is a better idea
and obviously what you are trying to do). To use cid: URLs, all the
related parts of the message (in this case the HTML part and the image)
need to be enclosed in a multipart/related message. You don't seem to do
that.

Here is an example using MIME::Lite to build an HTML mail with embedded
images. Adapting it to Email::MIME::Creator is left as an exercise to
the reader:

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

use MIME::Lite;

my $msg = MIME::Lite->new(
    From => 'hjp-usenet2@hjp.at',
    To   => 'hjp-usenet2@hjp.at',
    Subject => 'HTML test message',
    Type    => 'multipart/related; type=text/html',
);

my $unique = time();
my $tb_logo_cid = "tb-logo.$unique\@hjp.at";
my $smiley_cid = "smiley.$unique\@hjp.at";

$msg->attach(
    Type => 'text/html; charset=UTF-8',
    Data => "<title>Message text</title>\n" .
            "<h1>Hallo</h1>\n" .
            "<p>Hier ist ein Text mit einem Bild:</p>\n" .
            "<p><img alt='TB Logo' src='cid:$tb_logo_cid'></p>\n" .
            "<p>Es funktioniert! <img alt=':-)' src='cid:$smiley_cid'></p>\n",
);

my $part = MIME::Lite->new(
    Type         => 'image/png',
    Path         => 'Mozilla_Thunderbird_logo.png',
);
$part->attr('Content-Id', "<$tb_logo_cid>");
$msg->attach($part);

$part = MIME::Lite->new(
    Type         => 'image/gif',
    Path         => 'smiley16.gif',
);
$part->attr('Content-Id', "<$smiley_cid>");
$msg->attach($part);


$msg->print(\*STDOUT);
__END__

	hp


------------------------------

Date: Sat, 19 Jun 2010 16:02:56 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <slrni1pjgg.a5j.hjp-usenet2@hrunkner.hjp.at>

On 2010-06-19 02:00, Ted Byers <r.ted.byers@gmail.com> wrote:
> I wonder if I need to uuencode it,

No. Uuencode is sort of a precursor to MIME. You should use either MIME
or uuencode, but not both. In fact, since MIME can do everything
uuencode can (and much more) and is actually standardized, you should
always use MIME and never use uuencode (unless you need to talk to some
legacy software from the 1980's).

	hp


------------------------------

Date: Mon, 21 Jun 2010 08:42:33 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <e015cdbc-7510-490a-8799-98f9672a97c2@x27g2000yqb.googlegroups.com>

On Jun 19, 9:56=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2010-06-18 22:22, Ted Byers <r.ted.by...@gmail.com> wrote:
>
>
>
> > While the html displays OK, the top haif of it is repeated at the end.
> > Equally badly, the link between the jpg file (containing the logo) and
> > the img tag in the html is broken.
>
> > The first few lines, showing the package I am using are:
> [...]
> > use Email::MIME::Creator;
> [...]
> > my $html_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "text/html",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> "$html_template",
> > );
> > my $image_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "image/jpg",
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0name =A0 =A0 =A0 =A0 =3D> "logo.jpg",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> io( "template.files/image002.jpg" )->all,
> > );
> > my @parts =3D ($html_part,$image_part);
> > my $message =3D Email::MIME->create(
> > =A0 =A0 =A0 header =3D> [
> > =A0 =A0 =A0 =A0 =A0 From =3D> 'con...@capitalbusinessservices.net',
> > =A0 =A0 =A0 =A0 =A0 To =A0 =3D> 'r.ted.by...@gmail.com',
> > =A0 =A0 =A0Subject =3D> $subject,
> > =A0 =A0 =A0 ],
> > =A0 =A0 =A0 parts =3D> \@parts,
> > );
> [...]
> > It could hardly be simpler.
>
> > The img tag is:
>
> ><img width=3D634 height=3D95 src=3D"logo.jpg" v:shapes=3D"_x0000_i1025">
>
> That doesn't work. You cannot use a relative URL like "logo.jpg" in an
> email. You can either use an http: URL (but many mailers won't resolve
> them by default for privacy reasons (google "web bugs" for details)) or
> a cid: URL to refer to an image within the email (this is a better idea
> and obviously what you are trying to do). To use cid: URLs, all the
> related parts of the message (in this case the HTML part and the image)
> need to be enclosed in a multipart/related message. You don't seem to do
> that.
>
> Here is an example using MIME::Lite to build an HTML mail with embedded
> images. Adapting it to Email::MIME::Creator is left as an exercise to
> the reader:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> use MIME::Lite;
>
> my $msg =3D MIME::Lite->new(
> =A0 =A0 From =3D> 'hjp-usen...@hjp.at',
> =A0 =A0 To =A0 =3D> 'hjp-usen...@hjp.at',
> =A0 =A0 Subject =3D> 'HTML test message',
> =A0 =A0 Type =A0 =A0=3D> 'multipart/related; type=3Dtext/html',
> );
>
> my $unique =3D time();
> my $tb_logo_cid =3D "tb-logo.$unique\@hjp.at";
> my $smiley_cid =3D "smiley.$unique\@hjp.at";
>
> $msg->attach(
> =A0 =A0 Type =3D> 'text/html; charset=3DUTF-8',
> =A0 =A0 Data =3D> "<title>Message text</title>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<h1>Hallo</h1>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p>Hier ist ein Text mit einem Bild:</p>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p><img alt=3D'TB Logo' src=3D'cid:$tb_logo_cid'=
></p>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p>Es funktioniert! <img alt=3D':-)' src=3D'cid:=
$smiley_cid'></p>\n",
> );
>
> my $part =3D MIME::Lite->new(
> =A0 =A0 Type =A0 =A0 =A0 =A0 =3D> 'image/png',
> =A0 =A0 Path =A0 =A0 =A0 =A0 =3D> 'Mozilla_Thunderbird_logo.png',
> );
> $part->attr('Content-Id', "<$tb_logo_cid>");
> $msg->attach($part);
>
> $part =3D MIME::Lite->new(
> =A0 =A0 Type =A0 =A0 =A0 =A0 =3D> 'image/gif',
> =A0 =A0 Path =A0 =A0 =A0 =A0 =3D> 'smiley16.gif',
> );
> $part->attr('Content-Id', "<$smiley_cid>");
> $msg->attach($part);
>
> $msg->print(\*STDOUT);
> __END__
>
> =A0 =A0 =A0 =A0 hp
Thanks All,

I have tried everything suggested in this thread.  Always the result
was the same, even after using cid as directed.  I do not understand
why.

However, I do have progress.

In my quest for additional information, I found
Email::MIME::CreateHTML.  It does make things much simpler.  With it,
I need only two statements to make the message:

my %objects =3D (
                "logo.jpg" =3D> "template.files/image002.jpg"
        );

$message =3D Email::MIME->create_html(
                header =3D> [
                        From =3D> $from_user,
                        To =3D> $to_user,
                        Subject =3D> "testing Connie's email",
                ],
                body =3D> $html_template,
                embed =3D> 0, #<--
                inline_css =3D> 0,     #<--
                objects =3D> \%objects #<--
        );

The improvement this produces is twofold.  First, the html body is
invariably properly displayed.  Second, ythe linked in image is
displayed in the right place.  However, also invariably, only half of
the logo.jpg is displayed; this despite there being enough space being
available in the browser to display it all.

The body of the html file now begins with:

<p><img width=3D"634" height=3D"95" src=3D'cid:logo.jpg'></p>

NB: The result is the same regardless of whether I use a file named
logo.jpg or template.files/image002.jpg.

If I use the following:

my $logo =3D io( "logo.jpg" )->binary->all;
open(FOUT,"> logo.output.jpg");
binmode(FOUT);
print FOUT $logo;
close(FOUT);

I can compare the images using both  Windows explorer and Irfanview,
and the files (logo.jpg and logo.output.jpg) are identical.  However,
when I download and examine the image that accompanies the email, I
see it is defective.

Any ideas on why the image sent with the email is defective and how
that can be fixed?

Thanks

Ted


------------------------------

Date: Mon, 21 Jun 2010 08:43:12 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <5e21b92f-d0ae-494f-ae5f-9b863b7d2ec5@z8g2000yqz.googlegroups.com>

On Jun 19, 9:56=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2010-06-18 22:22, Ted Byers <r.ted.by...@gmail.com> wrote:
>
>
>
> > While the html displays OK, the top haif of it is repeated at the end.
> > Equally badly, the link between the jpg file (containing the logo) and
> > the img tag in the html is broken.
>
> > The first few lines, showing the package I am using are:
> [...]
> > use Email::MIME::Creator;
> [...]
> > my $html_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "text/html",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> "$html_template",
> > );
> > my $image_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "image/jpg",
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0name =A0 =A0 =A0 =A0 =3D> "logo.jpg",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> io( "template.files/image002.jpg" )->all,
> > );
> > my @parts =3D ($html_part,$image_part);
> > my $message =3D Email::MIME->create(
> > =A0 =A0 =A0 header =3D> [
> > =A0 =A0 =A0 =A0 =A0 From =3D> 'con...@capitalbusinessservices.net',
> > =A0 =A0 =A0 =A0 =A0 To =A0 =3D> 'r.ted.by...@gmail.com',
> > =A0 =A0 =A0Subject =3D> $subject,
> > =A0 =A0 =A0 ],
> > =A0 =A0 =A0 parts =3D> \@parts,
> > );
> [...]
> > It could hardly be simpler.
>
> > The img tag is:
>
> ><img width=3D634 height=3D95 src=3D"logo.jpg" v:shapes=3D"_x0000_i1025">
>
> That doesn't work. You cannot use a relative URL like "logo.jpg" in an
> email. You can either use an http: URL (but many mailers won't resolve
> them by default for privacy reasons (google "web bugs" for details)) or
> a cid: URL to refer to an image within the email (this is a better idea
> and obviously what you are trying to do). To use cid: URLs, all the
> related parts of the message (in this case the HTML part and the image)
> need to be enclosed in a multipart/related message. You don't seem to do
> that.
>
> Here is an example using MIME::Lite to build an HTML mail with embedded
> images. Adapting it to Email::MIME::Creator is left as an exercise to
> the reader:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> use MIME::Lite;
>
> my $msg =3D MIME::Lite->new(
> =A0 =A0 From =3D> 'hjp-usen...@hjp.at',
> =A0 =A0 To =A0 =3D> 'hjp-usen...@hjp.at',
> =A0 =A0 Subject =3D> 'HTML test message',
> =A0 =A0 Type =A0 =A0=3D> 'multipart/related; type=3Dtext/html',
> );
>
> my $unique =3D time();
> my $tb_logo_cid =3D "tb-logo.$unique\@hjp.at";
> my $smiley_cid =3D "smiley.$unique\@hjp.at";
>
> $msg->attach(
> =A0 =A0 Type =3D> 'text/html; charset=3DUTF-8',
> =A0 =A0 Data =3D> "<title>Message text</title>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<h1>Hallo</h1>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p>Hier ist ein Text mit einem Bild:</p>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p><img alt=3D'TB Logo' src=3D'cid:$tb_logo_cid'=
></p>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p>Es funktioniert! <img alt=3D':-)' src=3D'cid:=
$smiley_cid'></p>\n",
> );
>
> my $part =3D MIME::Lite->new(
> =A0 =A0 Type =A0 =A0 =A0 =A0 =3D> 'image/png',
> =A0 =A0 Path =A0 =A0 =A0 =A0 =3D> 'Mozilla_Thunderbird_logo.png',
> );
> $part->attr('Content-Id', "<$tb_logo_cid>");
> $msg->attach($part);
>
> $part =3D MIME::Lite->new(
> =A0 =A0 Type =A0 =A0 =A0 =A0 =3D> 'image/gif',
> =A0 =A0 Path =A0 =A0 =A0 =A0 =3D> 'smiley16.gif',
> );
> $part->attr('Content-Id', "<$smiley_cid>");
> $msg->attach($part);
>
> $msg->print(\*STDOUT);
> __END__
>
> =A0 =A0 =A0 =A0 hp
Thanks All,

I have tried everything suggested in this thread.  Always the result
was the same, even after using cid as directed.  I do not understand
why.

However, I do have progress.

In my quest for additional information, I found
Email::MIME::CreateHTML.  It does make things much simpler.  With it,
I need only two statements to make the message:

my %objects =3D (
                "logo.jpg" =3D> "template.files/image002.jpg"
        );

$message =3D Email::MIME->create_html(
                header =3D> [
                        From =3D> $from_user,
                        To =3D> $to_user,
                        Subject =3D> "testing Connie's email",
                ],
                body =3D> $html_template,
                embed =3D> 0, #<--
                inline_css =3D> 0,     #<--
                objects =3D> \%objects #<--
        );

The improvement this produces is twofold.  First, the html body is
invariably properly displayed.  Second, ythe linked in image is
displayed in the right place.  However, also invariably, only half of
the logo.jpg is displayed; this despite there being enough space being
available in the browser to display it all.

The body of the html file now begins with:

<p><img width=3D"634" height=3D"95" src=3D'cid:logo.jpg'></p>

NB: The result is the same regardless of whether I use a file named
logo.jpg or template.files/image002.jpg.

If I use the following:

my $logo =3D io( "logo.jpg" )->binary->all;
open(FOUT,"> logo.output.jpg");
binmode(FOUT);
print FOUT $logo;
close(FOUT);

I can compare the images using both  Windows explorer and Irfanview,
and the files (logo.jpg and logo.output.jpg) are identical.  However,
when I download and examine the image that accompanies the email, I
see it is defective.

Any ideas on why the image sent with the email is defective and how
that can be fixed?

Thanks

Ted


------------------------------

Date: Mon, 21 Jun 2010 09:02:38 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: problem sending email using MIME::Lite from gmail's stmp server
Message-Id: <ba1fd570-c223-4a86-b617-9dba3589ab9b@b29g2000vbl.googlegroups.com>

On Jun 19, 9:56=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2010-06-18 22:22, Ted Byers <r.ted.by...@gmail.com> wrote:
>
>
>
> > While the html displays OK, the top haif of it is repeated at the end.
> > Equally badly, the link between the jpg file (containing the logo) and
> > the img tag in the html is broken.
>
> > The first few lines, showing the package I am using are:
> [...]
> > use Email::MIME::Creator;
> [...]
> > my $html_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "text/html",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> "$html_template",
> > );
> > my $image_part =3D Email::MIME->create(
> > =A0 =A0 =A0 =A0 =A0 attributes =3D> {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0content_type =3D> "image/jpg",
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0name =A0 =A0 =A0 =A0 =3D> "logo.jpg",
> > =A0 =A0 =A0 =A0 =A0 },
> > =A0 =A0 =A0 =A0 =A0 body =3D> io( "template.files/image002.jpg" )->all,
> > );
> > my @parts =3D ($html_part,$image_part);
> > my $message =3D Email::MIME->create(
> > =A0 =A0 =A0 header =3D> [
> > =A0 =A0 =A0 =A0 =A0 From =3D> 'con...@capitalbusinessservices.net',
> > =A0 =A0 =A0 =A0 =A0 To =A0 =3D> 'r.ted.by...@gmail.com',
> > =A0 =A0 =A0Subject =3D> $subject,
> > =A0 =A0 =A0 ],
> > =A0 =A0 =A0 parts =3D> \@parts,
> > );
> [...]
> > It could hardly be simpler.
>
> > The img tag is:
>
> ><img width=3D634 height=3D95 src=3D"logo.jpg" v:shapes=3D"_x0000_i1025">
>
> That doesn't work. You cannot use a relative URL like "logo.jpg" in an
> email. You can either use an http: URL (but many mailers won't resolve
> them by default for privacy reasons (google "web bugs" for details)) or
> a cid: URL to refer to an image within the email (this is a better idea
> and obviously what you are trying to do). To use cid: URLs, all the
> related parts of the message (in this case the HTML part and the image)
> need to be enclosed in a multipart/related message. You don't seem to do
> that.
>
> Here is an example using MIME::Lite to build an HTML mail with embedded
> images. Adapting it to Email::MIME::Creator is left as an exercise to
> the reader:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> use MIME::Lite;
>
> my $msg =3D MIME::Lite->new(
> =A0 =A0 From =3D> 'hjp-usen...@hjp.at',
> =A0 =A0 To =A0 =3D> 'hjp-usen...@hjp.at',
> =A0 =A0 Subject =3D> 'HTML test message',
> =A0 =A0 Type =A0 =A0=3D> 'multipart/related; type=3Dtext/html',
> );
>
> my $unique =3D time();
> my $tb_logo_cid =3D "tb-logo.$unique\@hjp.at";
> my $smiley_cid =3D "smiley.$unique\@hjp.at";
>
> $msg->attach(
> =A0 =A0 Type =3D> 'text/html; charset=3DUTF-8',
> =A0 =A0 Data =3D> "<title>Message text</title>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<h1>Hallo</h1>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p>Hier ist ein Text mit einem Bild:</p>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p><img alt=3D'TB Logo' src=3D'cid:$tb_logo_cid'=
></p>\n" .
> =A0 =A0 =A0 =A0 =A0 =A0 "<p>Es funktioniert! <img alt=3D':-)' src=3D'cid:=
$smiley_cid'></p>\n",
> );
>
> my $part =3D MIME::Lite->new(
> =A0 =A0 Type =A0 =A0 =A0 =A0 =3D> 'image/png',
> =A0 =A0 Path =A0 =A0 =A0 =A0 =3D> 'Mozilla_Thunderbird_logo.png',
> );
> $part->attr('Content-Id', "<$tb_logo_cid>");
> $msg->attach($part);
>
> $part =3D MIME::Lite->new(
> =A0 =A0 Type =A0 =A0 =A0 =A0 =3D> 'image/gif',
> =A0 =A0 Path =A0 =A0 =A0 =A0 =3D> 'smiley16.gif',
> );
> $part->attr('Content-Id', "<$smiley_cid>");
> $msg->attach($part);
>
> $msg->print(\*STDOUT);
> __END__
>
> =A0 =A0 =A0 =A0 hp
Thanks All,

I have tried everything suggested in this thread.  Always the result
was the same, even after using cid as directed.  I do not understand
why.

However, I do have progress.

In my quest for additional information, I found
Email::MIME::CreateHTML.  It does make things much simpler.  With it,
I need only two statements to make the message:

my %objects =3D (
                "logo.jpg" =3D> "template.files/image002.jpg"
        );

$message =3D Email::MIME->create_html(
                header =3D> [
                        From =3D> $from_user,
                        To =3D> $to_user,
                        Subject =3D> "testing Connie's email",
                ],
                body =3D> $html_template,
                embed =3D> 0, #<--
                inline_css =3D> 0,     #<--
                objects =3D> \%objects #<--
        );

The improvement this produces is twofold.  First, the html body is
invariably properly displayed.  Second, ythe linked in image is
displayed in the right place.  However, also invariably, only half of
the logo.jpg is displayed; this despite there being enough space being
available in the browser to display it all.

The body of the html file now begins with:

<p><img width=3D"634" height=3D"95" src=3D'cid:logo.jpg'></p>

NB: The result is the same regardless of whether I use a file named
logo.jpg or template.files/image002.jpg.

If I use the following:

my $logo =3D io( "logo.jpg" )->binary->all;
open(FOUT,"> logo.output.jpg");
binmode(FOUT);
print FOUT $logo;
close(FOUT);

I can compare the images using both  Windows explorer and Irfanview,
and the files (logo.jpg and logo.output.jpg) are identical.  However,
when I download and examine the image that accompanies the email, I
see it is defective.

Any ideas on why the image sent with the email is defective and how
that can be fixed?

Thanks

Ted


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2997
***************************************


home help back first fref pref prev next nref lref last post