[31735] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2998 Volume: 11

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

Date: Mon, 21 Jun 2010 18:09:06 -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: 2998

Today's topics:
        DB_File (hash of array) problem <hslee911@yahoo.com>
    Re: How to submit utility - not module - to CPAN <sreservoir@gmail.com>
        paypal wholesale adidas shoes (paypal payment and free  <jiazhao99@yahoo.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>
    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: Mon, 21 Jun 2010 17:15:51 -0700 (PDT)
From: James <hslee911@yahoo.com>
Subject: DB_File (hash of array) problem
Message-Id: <d6a07367-eb17-489e-bed8-a22f3caa8f72@z15g2000prh.googlegroups.com>

I am trying to write to a database a hash of array (as seen by
__DATA__ in the code).
But somehow the first element of the array is missing. Any idea why?
The second time, it is working correctly.

$ cat run.pl
use DB_File;
use vars qw($db $x %h $k $v $i $key $val);

($db) = @ARGV;

%h = ();
$x = tie %h, "DB_File", $db, O_RDWR|O_CREAT, 0640, $DB_HASH;
write_db();
read_db();
untie %h;
undef $x;

sub write_db {
print "=== write $db ===\n";
for (<DATA>)
{
        ($k, @v) = split;
        print "$k -> @v\n";
        $r = \@v;
        for $i (0..$#v) {
                $h{$k}->[$i] = $r->[$i];
        }
}
}

sub read_db {
print "=== read $db ===\n";
for ( $status = $x->seq($key, $val, R_FIRST); $status == 0; $status =
$x->seq($key, $val, R_NEXT) )
{
        print "$key -> @{$val}\n";
}
}

__DATA__
aa 1 2 3
cc 678 99
zz foo fee fuu fun

$ ./run.pl mydb
=== write mydb ===
aa -> 1 2 3
cc -> 678 99
zz -> foo fee fuu fun
=== read mydb ===
aa ->  2 3
cc ->  99
zz ->  fee fuu fun



TIA
JL


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

Date: Mon, 21 Jun 2010 18:14:25 -0400
From: sreservoir <sreservoir@gmail.com>
Subject: Re: How to submit utility - not module - to CPAN
Message-Id: <hvoo81$hnf$1@speranza.aioe.org>

On 6/21/2010 11:34 AM, Steve Roscio wrote:
> 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?

I _think_ PPT is just using a dummy module. but don't quote me on that.

perhaps install it in a sandbox and see what it does.

-- 

  "Six by nine. Forty two."
  "That's it. That's all there is."
  "I always thought something was fundamentally wrong with the universe."


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

Date: Mon, 21 Jun 2010 18:05:23 -0700 (PDT)
From: world-trade <jiazhao99@yahoo.com>
Subject: paypal wholesale adidas shoes (paypal payment and free shipping)
Message-Id: <9c22d353-2bd9-49bf-a4d0-38aa9bdf5be7@o28g2000prh.googlegroups.com>

paypal wholesale d&g shoes (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale gucci shoes (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale lv shoes (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale NBA shoes (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale nike (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale adidas shoes (paypal payment
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale UGG shoes (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale bape hoody (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale antick jeans (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale diesel jeans (paypal payment
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale artful dudger (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale bag(lv gucci coach chanel d&g dior ed  fendi )

(paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale clothing (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale lrg,jeans,hoody, (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale evisu jeans,hoody,shirt (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)

paypal wholesale Prada (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale Puma (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale Sand (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale Shox (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale soccer (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale UGG (paypal payment
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale Versace (paypal payment)
(http://picasaweb.google.de/peopletrade.clothing002/ )
paypal wholesale Women (paypal payment
(http://picasaweb.google.de/peopletrade.clothing002/)
paypal wholesale Y-3 (paypal payment)
(www.bglobaltrade06.com )


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

Date: Mon, 21 Jun 2010 13:14:15 -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: <bd056c64-1eb7-4525-8dff-8b3b6115e9ed@h13g2000yqm.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

OK, I am beginning to suspect there is a bug in Email::MIME
somewhere.  I know the files I am using to make the email are OK,
since, if I replace the content of the email you construct in your
example, and send it from my exchange server, the result is perfect
except that it is sent from the wrong email address.  The email
address that should be used exists only on the gmail account I have
been trying to use.

I can send email using the following, but the image is cut in half:

use strict;
use warnings;

use Email::MIME::CreateHTML;
use Email::Sender::Transport::SMTP::TLS;

#example modified so that there is text after image as well as before
it
my $html =3D qq{
                <html><head><title>My Document</title></head><body>
                        <p>Here is a picture:</p><img
src=3D"cid:logo.jpg"></p><p>qwerty qwerty</p>
                </body></html>
        };
my %objects =3D (
                "logo.jpg" =3D> "template.files/image002.jpg"
        );
my $quick_to_assemble_mime =3D Email::MIME->create_html(
                header =3D> [
                        From =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
                        To =3D> 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ',
                        Subject =3D> 'My speedy HTML',
                ],
                body =3D> $html,
                embed =3D> 0,          #<--
                inline_css =3D> 0,     #<--
                objects =3D> \%objects #<--
        );
my $sender =3D Email::Sender::Transport::SMTP::TLS->new(
        host =3D> 'smtp.gmail.com',
        port =3D> 587,
        username =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
        password =3D> 'XXXXXXXXXXXXX',
    );
eval {
        $sender->send($quick_to_assemble_mime, {
            from =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
            to   =3D> [ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' ],
        } );
    } or die "Error sending email: $@";

In fact, if I tell it to use the png version of the logo, the image
does not display at all, and instead, if I select it from thelist of
attachments to view it, I get an error message that it is damaged.
But the original file as it exists on my machine is perfect.  What
else can it be but Email::MIME->create_html (or rather the Email::MIME
package it uses) breaking my graphics files?  We know that it isn't
the link between the html and the jpg file that is broken, because the
part of the jpg that is maintained appears in the right place.
Rather, it must be a problem with how it is handling the binary data
in the jpg (and png file).

I am stuck with two options, each of which has a show stopper
problem.  If I use MIME::Lite, I can't connect to gmail in order to
send the email from the right email address, and if I use Email::MIME-
>create_html, my graphics files are damaged (as sent within the
email).  I will be content if I can have a viable solution to either
so that at least I can assemble and send the emails.

Thanks

Ted


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

Date: Mon, 21 Jun 2010 13:23:02 -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: <09575041-c53b-470f-b4d7-8906167bfb3a@5g2000yqz.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

OK, I am beginning to suspect there is a bug in Email::MIME
somewhere.  I know the files I am using to make the email are OK,
since, if I replace the content of the email you construct in your
example, and send it from my exchange server, the result is perfect
except that it is sent from the wrong email address.  The email
address that should be used exists only on the gmail account I have
been trying to use.

I can send email using the following, but the image is cut in half:

use strict;
use warnings;

use Email::MIME::CreateHTML;
use Email::Sender::Transport::SMTP::TLS;

#example modified so that there is text after image as well as before
it
my $html =3D qq{
                <html><head><title>My Document</title></head><body>
                        <p>Here is a picture:</p><img
src=3D"cid:logo.jpg"></p><p>qwerty qwerty</p>
                </body></html>
        };
my %objects =3D (
                "logo.jpg" =3D> "template.files/image002.jpg"
        );
my $quick_to_assemble_mime =3D Email::MIME->create_html(
                header =3D> [
                        From =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
                        To =3D> 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ',
                        Subject =3D> 'My speedy HTML',
                ],
                body =3D> $html,
                embed =3D> 0,          #<--
                inline_css =3D> 0,     #<--
                objects =3D> \%objects #<--
        );
my $sender =3D Email::Sender::Transport::SMTP::TLS->new(
        host =3D> 'smtp.gmail.com',
        port =3D> 587,
        username =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
        password =3D> 'XXXXXXXXXXXXX',
    );
eval {
        $sender->send($quick_to_assemble_mime, {
            from =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
            to   =3D> [ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' ],
        } );
    } or die "Error sending email: $@";

In fact, if I tell it to use the png version of the logo, the image
does not display at all, and instead, if I select it from thelist of
attachments to view it, I get an error message that it is damaged.
But the original file as it exists on my machine is perfect.  What
else can it be but Email::MIME->create_html (or rather the Email::MIME
package it uses) breaking my graphics files?  We know that it isn't
the link between the html and the jpg file that is broken, because the
part of the jpg that is maintained appears in the right place.
Rather, it must be a problem with how it is handling the binary data
in the jpg (and png file).

I am stuck with two options, each of which has a show stopper
problem.  If I use MIME::Lite, I can't connect to gmail in order to
send the email from the right email address, and if I use Email::MIME-
>create_html, my graphics files are damaged (as sent within the
email).  I will be content if I can have a viable solution to either
so that at least I can assemble and send the emails.

Thanks

Ted


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

Date: Mon, 21 Jun 2010 13:27:03 -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: <64a8b2f0-b6dc-4a35-a11a-1c648f07bce9@u7g2000yqm.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

OK, I am beginning to suspect there is a bug in Email::MIME
somewhere.  I know the files I am using to make the email are OK,
since, if I replace the content of the email you construct in your
example, and send it from my exchange server, the result is perfect
except that it is sent from the wrong email address.  The email
address that should be used exists only on the gmail account I have
been trying to use.

I can send email using the following, but the image is cut in half:

use strict;
use warnings;

use Email::MIME::CreateHTML;
use Email::Sender::Transport::SMTP::TLS;

#example modified so that there is text after image as well as before
it
my $html =3D qq{
                <html><head><title>My Document</title></head><body>
                        <p>Here is a picture:</p><img
src=3D"cid:logo.jpg"></p><p>qwerty qwerty</p>
                </body></html>
        };
my %objects =3D (
                "logo.jpg" =3D> "template.files/image002.jpg"
        );
my $quick_to_assemble_mime =3D Email::MIME->create_html(
                header =3D> [
                        From =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
                        To =3D> 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ',
                        Subject =3D> 'My speedy HTML',
                ],
                body =3D> $html,
                embed =3D> 0,          #<--
                inline_css =3D> 0,     #<--
                objects =3D> \%objects #<--
        );
my $sender =3D Email::Sender::Transport::SMTP::TLS->new(
        host =3D> 'smtp.gmail.com',
        port =3D> 587,
        username =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
        password =3D> 'XXXXXXXXXXXXX',
    );
eval {
        $sender->send($quick_to_assemble_mime, {
            from =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
            to   =3D> [ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' ],
        } );
    } or die "Error sending email: $@";

In fact, if I tell it to use the png version of the logo, the image
does not display at all, and instead, if I select it from thelist of
attachments to view it, I get an error message that it is damaged.
But the original file as it exists on my machine is perfect.  What
else can it be but Email::MIME->create_html (or rather the Email::MIME
package it uses) breaking my graphics files?  We know that it isn't
the link between the html and the jpg file that is broken, because the
part of the jpg that is maintained appears in the right place.
Rather, it must be a problem with how it is handling the binary data
in the jpg (and png file).

I am stuck with two options, each of which has a show stopper
problem.  If I use MIME::Lite, I can't connect to gmail in order to
send the email from the right email address, and if I use Email::MIME-
>create_html, my graphics files are damaged (as sent within the
email).  I will be content if I can have a viable solution to either
so that at least I can assemble and send the emails.

Thanks

Ted


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

Date: Mon, 21 Jun 2010 13:37:16 -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: <5d83cd55-f437-413d-95ca-f88f7c85471c@y4g2000yqy.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

OK, I am beginning to suspect there is a bug in Email::MIME
somewhere.  I know the files I am using to make the email are OK,
since, if I replace the content of the email you construct in your
example, and send it from my exchange server, the result is perfect
except that it is sent from the wrong email address.  The email
address that should be used exists only on the gmail account I have
been trying to use.

I can send email using the following, but the image is cut in half:

use strict;
use warnings;

use Email::MIME::CreateHTML;
use Email::Sender::Transport::SMTP::TLS;

#example modified so that there is text after image as well as before
it
my $html =3D qq{
                <html><head><title>My Document</title></head><body>
                        <p>Here is a picture:</p><img
src=3D"cid:logo.jpg"></p><p>qwerty qwerty</p>
                </body></html>
        };
my %objects =3D (
                "logo.jpg" =3D> "template.files/image002.jpg"
        );
my $quick_to_assemble_mime =3D Email::MIME->create_html(
                header =3D> [
                        From =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
                        To =3D> 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ',
                        Subject =3D> 'My speedy HTML',
                ],
                body =3D> $html,
                embed =3D> 0,          #<--
                inline_css =3D> 0,     #<--
                objects =3D> \%objects #<--
        );
my $sender =3D Email::Sender::Transport::SMTP::TLS->new(
        host =3D> 'smtp.gmail.com',
        port =3D> 587,
        username =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
        password =3D> 'XXXXXXXXXXXXX',
    );
eval {
        $sender->send($quick_to_assemble_mime, {
            from =3D> 'YYYYYYYYYYYYYYYYYYYYYYY',
            to   =3D> [ 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' ],
        } );
    } or die "Error sending email: $@";

In fact, if I tell it to use the png version of the logo, the image
does not display at all, and instead, if I select it from thelist of
attachments to view it, I get an error message that it is damaged.
But the original file as it exists on my machine is perfect.  What
else can it be but Email::MIME->create_html (or rather the Email::MIME
package it uses) breaking my graphics files?  We know that it isn't
the link between the html and the jpg file that is broken, because the
part of the jpg that is maintained appears in the right place.
Rather, it must be a problem with how it is handling the binary data
in the jpg (and png file).

I am stuck with two options, each of which has a show stopper
problem.  If I use MIME::Lite, I can't connect to gmail in order to
send the email from the right email address, and if I use Email::MIME-
>create_html, my graphics files are damaged (as sent within the
email).  I will be content if I can have a viable solution to either
so that at least I can assemble and send the emails.

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 2998
***************************************


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