Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Email::MIME requires encoding & charset #35

Merged
merged 1 commit into from

4 participants

@madsen

The "Sending an email" example does not work as written. You get the error "body_str was given, but no charset is defined at /usr/local/share/perl/5.10.1/Email/MIME.pm line 243". See this question on Stack Overflow.

Also, an email body should normally end with a newline

@madsen madsen Email::MIME requires encoding & charset
  Also, an email body should normally end with a newline
472420b
@abh abh merged commit 6e50a44 into perlorg:master
@abh
Owner

Thanks!

Wouldn't it (maybe) make sense to have the example encode with utf-8 instead?

@madsen

Well, you have to leave something for the student to figure out. :-)

It doesn't really matter, since the body is actually US-ASCII.

@madsen

I just noticed that same broken example also appears here on the FAQ page. But that file says "DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq", and I'm not sure where the source for that is.

@abh
Owner

@ranguard the canonical source for the perlfaq is at https://github.com/tpf/perlfaq - or?

@ranguard
Owner

Yep, although we prefer patches / pull requests to https://github.com/perl-doc-cats/perlfaq - which is then released to https://github.com/tpf/perlfaq before going to CPAN.

@apeiron

@madsen Leaving the student to get UTF-8 right is a terrible idea, considering how many skilled programmers get it wrong. I'll merge something derived from the above into the perlfaq that handles UTF-8 properly for the user. The point of the FAQ is to answer hard questions for them, not let them figure out the hard stuff on their own and get it wrong.

@madsen madsen referenced this pull request in perl-doc-cats/perlfaq
Merged

Email::MIME requires encoding & charset #30

@ranguard
Owner

@madsen - thanks for reporting this - now updated in the perlfaq as well (which will update on the website shortly), I also updated the comment about not to update the file so that it mentions the perlfaq gitrepo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 13, 2012
  1. @madsen

    Email::MIME requires encoding & charset

    madsen authored
      Also, an email body should normally end with a newline
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +6 −2 docs/learn/examples/email.html
View
8 docs/learn/examples/email.html
@@ -13,10 +13,14 @@
To => 'friend@example.com',
Subject => 'Happy birthday!',
],
- body_str => 'Happy birthday to you!',
+ attributes => {
+ encoding => 'quoted-printable',
+ charset => 'ISO-8859-1',
+ },
+ body_str => "Happy birthday to you!\n",
);
# send the message
use Email::Sender::Simple qw(sendmail);
sendmail($message);
-[%- END %]
+[%- END %]
Something went wrong with that request. Please try again.