Re: Sending simple email

2009-06-07 Thread Bill Moseley
On Sat, Jun 06, 2009 at 12:01:40PM -0400, Ricardo SIGNES wrote:
 * Bill Moseley mose...@hank.org [2009-06-06T11:34:29]
  I see the recommendation to use Email::Sender, but are there docs
  available?
 
 You have sent this message at an excellent time!  Email::Sender::Simple is
 potentially done, and I've written a quickstart guide, just last night.
 
   http://rjbs.manxome.org/tmp/QuickStart.html

Looks pretty good.  Thanks.

Any plans to add simple attachments?  Like I mentioned, one of the
more common tasks for apps I work on seem to be attaching pdfs and
spreadsheets.


 
  I tend to either send plain text or html formatted messages.  If I
  send an html messages and I don't also have a plain text version I
  want to extract text and links from the html to make a plain text
  part.
 
 You might like the BBC's Email::MIME::CreateHTML:
 
   Email-MIME-CreateHTML
 
 I think it does everything you want.

I looked at that and I don't think it will create the plain text
version automatically from the html, but I'll take a look again.

Thanks,

-- 
Bill Moseley.
mose...@hank.org
Sent from my iMutt


Re: Sending simple email

2009-06-07 Thread Ricardo SIGNES
* Bill Moseley mose...@hank.org [2009-06-07T19:07:34]
 On Sat, Jun 06, 2009 at 12:01:40PM -0400, Ricardo SIGNES wrote:
  You have sent this message at an excellent time!  Email::Sender::Simple is
  potentially done, and I've written a quickstart guide, just last night.
  
http://rjbs.manxome.org/tmp/QuickStart.html
 
 Looks pretty good.  Thanks.
 
 Any plans to add simple attachments?  Like I mentioned, one of the
 more common tasks for apps I work on seem to be attaching pdfs and
 spreadsheets.

Well, Email::Sender doesn't deal with attachments at all.  It doesn't know
what's in your message, beyond *maybe* looking at the to/from headers.
Attachment stuff is all handled by Email::MIME.

Can you give me an idea what the Perl you want to write would look like?

  You might like the BBC's Email::MIME::CreateHTML:
  
Email-MIME-CreateHTML
  
  I think it does everything you want.
 
 I looked at that and I don't think it will create the plain text
 version automatically from the html, but I'll take a look again.

You're right, oops.  In these circumstances I do one of three things:

  a) shell out to w3m (ugh!)
  b) only write the plaintext part, in Markdown, and use that to generate both
 (see http://search.cpan.org/dist/Email-MIME-Kit-Assembler-Markdown)
  c) use HTML::FormatText::WithLinks

-- 
rjbs


Re: Sending simple email

2009-06-07 Thread Bill Moseley
On Sun, Jun 07, 2009 at 07:28:13PM -0400, Ricardo SIGNES wrote:
 Well, Email::Sender doesn't deal with attachments at all.  It doesn't know
 what's in your message, beyond *maybe* looking at the to/from headers.
 Attachment stuff is all handled by Email::MIME.
 
 Can you give me an idea what the Perl you want to write would look like?

Well, Mail::Sender has something close.  I haven't used that module
before but it looks like this:

$sender-MailFile({
to  = $to,
cc  = $cc,
subject = 'May 2009 Monthly Report',
msg = 'Attached is the report you requested.',
file= $spreadsheet_filename,
});

But, I don't think it does any MIME detection of the file.
That's a bit tricky -- MIME::Types or File::LibMagic could be used.

It's pretty simplistic, but probably a large percentage of email would
be handled by that.  Everything (except subject) takes a scalar or an
array ref.


-- 
Bill Moseley.
mose...@hank.org
Sent from my iMutt