Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I would like to create a script that can plot a graph for me and email that graph out. I know how to email in perl, but was looking for pointers on plotting and pasting it in the email.

Thank you.

Replies are listed 'Best First'.
Re: plotting graphs
by eibwen (Friar) on Apr 24, 2005 at 20:11 UTC
    Perhaps search CPAN, which includes GD::Graph.

      ... and to pass an image in an e-mail, take a look at MIME::Tools or any of the other MIME utilities in CPAN.

Re: plotting graphs
by holli (Abbot) on Apr 25, 2005 at 07:37 UTC
Re: plotting graphs
by salva (Canon) on Apr 25, 2005 at 08:42 UTC
Re: plotting graphs
by TedPride (Priest) on Apr 25, 2005 at 07:31 UTC
    I've sort of been wondering how to include an image in email also. Can you just use an HTML image tag and load it from your web server? Or does every image have to actually be included in the email?
      You have to use "Id" and "cid:" tags to locate the image.
      #!/usr/bin/perl use MIME::Lite; my $from_address = 'selector@selectorweb.com'; my $to_address = 'selector@selectorweb.com'; my $subject = 'MIME test - HTML with image'; my $mime_type = 'multipart/related'; # Create the message headers my $mime_msg = MIME::Lite->new( From => $from_address, To => $to_address, Subject => $subject, Type => $mime_type ) or die "Error creating MIME body: $!\n"; # Attach the HTML content my $message_body = '<html><body><H3>Hello world! <img src="cid:myid.gif"></H3></body></html>'; $mime_msg->attach(Type => 'text/html', Data => $message_body); # Attach the image $mime_msg->attach( Type => 'image/gif', Id => 'myid.gif', Encoding => 'base64', Path => 'pikachu.jpg'); $mime_msg->send;

      I'm not really a human, but I play one on earth. flash japh

      For your own personal e-mail, you can send HTML formatting, and link to the images remotely. Because of spammers using 'web bugs' and the like to track if their e-mail was going through, many e-mail programs have options to not load images, so if you're sending it to other people, it may not be rendered as you might have hoped. If you're just sending images, and not trying to send a formatted message that includes images, just send them as a MIME attachment, and most modern e-mail readers will handle it.

      In the off chance that you are trying to send a richly formatted message that includes images, then follow zentara's directions. (I've never done it, but that looks like how some of the spam that I get is formatted)