HTML email question
Hi, I'm trying to write a very simple shell script which creates a simple hebrew text file, which is then being sent by email using sendmail. Here's the script, pretty basic one.. #!/bin/bash echo From: [EMAIL PROTECTED] mail.txt echo To: [EMAIL PROTECTED] mail.txt echo Subject: =?UTF-8 úéøáòá äòãåä= mail.txt echo 'Content-Type: text/html; charset=UTF-8;' mail.txt echo 'html xmlns=http://www.w3.org/1999/xhtml; dir=rtl xml:lang=he lang=he' mail.txt echo 'meta http-equiv=Content-Type content=text/html; charset=utf-8' mail.txt echo 'DIV id=main dir=rtl' mail.txt echo ?úéøáò ùé mail.txt echo !ãáåò äæ ïë íà mail.txt echo /DIV mail.txt echo /html mail.txt (the file has been edited by gvim in windows). The mail.txt comes out OK, but when I'm sending it to my gmail account, the incoming mail comes gybrish both in subject and the text. I admit, I have 0 experience creating HTML mails, is there any good link to learn how to make it correctly so users can see both subject and the html in good way? Thanks, Hetz -- Skepticism is the lazy person's default position. my blog (hebrew): http://benhamo.org
Re: HTML email question
On Wed, Nov 28, 2007 at 03:36:56PM +0200, Hetz Ben Hamo wrote: Hi, I'm trying to write a very simple shell script which creates a simple hebrew text file, which is then being sent by email using sendmail. Here's the script, pretty basic one.. #!/bin/bash echo From: [EMAIL PROTECTED] mail.txt echo To: [EMAIL PROTECTED] mail.txt echo Subject: =?UTF-8 úéøáòá äòãåä= mail.txt echo 'Content-Type: text/html; charset=UTF-8;' mail.txt echo 'html xmlns=http://www.w3.org/1999/xhtml; dir=rtl xml:lang=he lang=he' mail.txt echo 'meta http-equiv=Content-Type content=text/html; charset=utf-8' mail.txt echo 'DIV id=main dir=rtl' mail.txt echo ?úéøáò ùé mail.txt echo !ãáåò äæ ïë íà mail.txt echo /DIV mail.txt echo /html mail.txt (the file has been edited by gvim in windows). The mail.txt comes out OK, but when I'm sending it to my gmail account, the incoming mail comes gybrish both in subject and the text. I admit, I have 0 experience creating HTML mails, is there any good link to learn how to make it correctly so users can see both subject and the html in good way? I do not know. You might read rfc2045 and friends, or use some program/library that does this, or (probably simplest) send mail to yourself from a decent client (e.g. TB or gmail) and look at its source to see how it's constructed. Basically, you should use one of the available encodings supported by these RFCs and state which one(s) you chose - just like what you tried to do, only being more accurate. -- Didi To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: HTML email question
Hetz Ben Hamo wrote: Hi, I'm trying to write a very simple shell script which creates a simple hebrew text file, which is then being sent by email using sendmail. Here's the script, pretty basic one.. #!/bin/bash echo From: [EMAIL PROTECTED] mail.txt echo To: [EMAIL PROTECTED] mail.txt echo Subject: =?UTF-8 úéøáòá äòãåä= mail.txt IIRC, your subject should be in base64 encoding, since email headers should be pure ASCII. For example: Subject: =?UTF-8?B?16DXmdeh15nXldef?= breaks down like this: Subject: =?Encoding?B?base64 encoding of a UTF-8 string with hebrew?= echo 'Content-Type: text/html; charset=UTF-8;' mail.txt echo 'html xmlns=http://www.w3.org/1999/xhtml; dir=rtl xml:lang=he lang=he' mail.txt echo 'meta http-equiv=Content-Type content=text/html; charset=utf-8' mail.txt echo 'DIV id=main dir=rtl' mail.txt echo ?úéøáò ùé mail.txt echo !ãáåò äæ ïë íà mail.txt echo /DIV mail.txt echo /html mail.txt Since SMTP is by default supposed to be 7bit ASCII, you should either mime-encode your actual message body, or use the following header to try to pass 8bit encoding: Content-Transfer-Encoding: 8bit And for HTML only mail, you should also consider these headers: MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 (the file has been edited by gvim in windows). The mail.txt comes out OK, but when I'm sending it to my gmail account, the incoming mail comes gybrish both in subject and the text. I admit, I have 0 experience creating HTML mails, is there any good link to learn how to make it correctly so users can see both subject and the html in good way? Thanks, Hetz To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: HTML email question
On Wed, 2007-11-28 at 15:36 +0200, Hetz Ben Hamo wrote: I'm trying to write a very simple shell script which creates a simple hebrew text file, which is then being sent by email using sendmail. echo Subject: =?UTF-8 úéøáòá äòãåä= mail.txt Read RFC 1522 on how to encode non-7bit text into headers. you can use either base64 or quoted-printable to ascii armor your text and it requires a special format as Lior Okman noted. echo 'Content-Type: text/html; charset=UTF-8;' mail.txt echo 'html xmlns=http://www.w3.org/1999/xhtml; dir=rtl xml:lang=he lang=he' mail.txt I don't recall how the sendmail interface handles this, but I think you better make sure there's an empty line between the header and the subject. I admit, I have 0 experience creating HTML mails, is there any good link to learn how to make it correctly so users can see both subject and the html in good way? I recommend using MIME when sending HTML content - some clients don't handle non-MIME HTML all that well (mainly web mail clients). Read RFC 2822 or use some perl/ruby/python/whatever library to help you with that. A good library would also handle the 7bit transformation required. If you do want to use bash, I personally would forgo the interim text file and pipe directly to sendmail: #!/bin/bash ( echo To: [EMAIL PROTECTED] echo Subject: test echo echo This is just a test ) | sendmail or something... -- Oded To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: HTML email question
On Wed, Nov 28, 2007 at 05:40:33PM +0200, Hetz Ben Hamo wrote: Hi, On Nov 28, 2007 4:53 PM, Oded Arbel [EMAIL PROTECTED] wrote: On Wed, 2007-11-28 at 15:36 +0200, Hetz Ben Hamo wrote: I'm trying to write a very simple shell script which creates a simple hebrew text file, which is then being sent by email using sendmail. echo Subject: =?UTF-8 úéøáòá äòãåä= mail.txt Read RFC 1522 on how to encode non-7bit text into headers. you can use either base64 or quoted-printable to ascii armor your text and it requires a special format as Lior Okman noted. Oh boy, I love those RFC's (specially when they mention 1 thing, and the real world has other things) :) That's not true. A very small and inaccurate test I did with various clients showed that all common ones can be configured to obey these RFCs and they behave correctly when getting a complying message. The problems arise when a client is configured to not be compliant and sends emails that the other side, in order to parse, needs to play some heuristics. Anyway, I was wondering about a small issue which I cannot seem to find why it happens here.. see this: $ cat shalom.txt hello world $ base64 shalom.txt shalom.enc $ base64 -d shalom.enc hello world base64: invalid input Anyone knows why it's invalid input ? No idea, but as others suggested - I'd do this with a P-language, not sh. Usually their builtin MIME etc. library functions are much easier to work with. Google for your favourite one plus 'mime mail tutorial' and I think you'll get some good intros. -- Didi To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: HTML email question
Hi, On Nov 28, 2007 4:53 PM, Oded Arbel [EMAIL PROTECTED] wrote: On Wed, 2007-11-28 at 15:36 +0200, Hetz Ben Hamo wrote: I'm trying to write a very simple shell script which creates a simple hebrew text file, which is then being sent by email using sendmail. echo Subject: =?UTF-8 úéøáòá äòãåä= mail.txt Read RFC 1522 on how to encode non-7bit text into headers. you can use either base64 or quoted-printable to ascii armor your text and it requires a special format as Lior Okman noted. Oh boy, I love those RFC's (specially when they mention 1 thing, and the real world has other things) :) echo 'Content-Type: text/html; charset=UTF-8;' mail.txt echo 'html xmlns=http://www.w3.org/1999/xhtml; dir=rtl xml:lang=he lang=he' mail.txt I don't recall how the sendmail interface handles this, but I think you better make sure there's an empty line between the header and the subject. Ok, I admit, I have 0 experience creating HTML mails, is there any good link to learn how to make it correctly so users can see both subject and the html in good way? I recommend using MIME when sending HTML content - some clients don't handle non-MIME HTML all that well (mainly web mail clients). Read RFC 2822 or use some perl/ruby/python/whatever library to help you with that. A good library would also handle the 7bit transformation required. If you do want to use bash, I personally would forgo the interim text file and pipe directly to sendmail: #!/bin/bash ( echo To: [EMAIL PROTECTED] echo Subject: test echo echo This is just a test ) | sendmail Yes, the way you did is with text messages. I'm doing this already.. Anyway, I was wondering about a small issue which I cannot seem to find why it happens here.. see this: $ cat shalom.txt hello world $ base64 shalom.txt shalom.enc $ base64 -d shalom.enc hello world base64: invalid input Anyone knows why it's invalid input ? Thanks, Hetz -- Skepticism is the lazy person's default position. my blog (hebrew): http://benhamo.org
Re: HTML email question
Hi, Oh boy, I love those RFC's (specially when they mention 1 thing, and the real world has other things) :) That's not true. A very small and inaccurate test I did with various clients showed that all common ones can be configured to obey these RFCs and they behave correctly when getting a complying message. The problems arise when a client is configured to not be compliant and sends emails that the other side, in order to parse, needs to play some heuristics. Outlook 2000 (pre SP1) had tons of issues that I remember. No idea, but as others suggested - I'd do this with a P-language, not sh. Usually their builtin MIME etc. library functions are much easier to work with. Google for your favourite one plus 'mime mail tutorial' and I think you'll get some good intros. Yeah, I'm looking at PHP right now. Thanks for the help Didi, Oded, Lior :) Hetz -- Skepticism is the lazy person's default position. my blog (hebrew): http://benhamo.org = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: HTML email question
On Wed, 2007-11-28 at 18:38 +0200, Hetz Ben Hamo wrote: Hi, Oh boy, I love those RFC's (specially when they mention 1 thing, and the real world has other things) :) That's not true. A very small and inaccurate test I did with various clients showed that all common ones can be configured to obey these RFCs and they behave correctly when getting a complying message. The problems arise when a client is configured to not be compliant and sends emails that the other side, in order to parse, needs to play some heuristics. Outlook 2000 (pre SP1) had tons of issues that I remember. Indeed there are some issues - RFCs allow you several ways of doing stuff, either by explicitly allowing for multiple behaviors or by omitting definitions for trivial stuff (which apparently weren't all that trivial to the next implementor). Anyway - you do have to test your application against multiple clients. Some things which are legal according to the RFC will not be handled well by some clients and the exact problem is often very hard to nail down. I usually test Outlook 2003, Outlook Express, Thunderbird, GMail, Evolution and Sometimes KMail. Evolution and Thunderbird are usually the easiest to work with - the eat everything that is legal and even a few things that aren't and are happy to show you what you expect. GMail is the worst - you can get it to use almost any feature of MIME/HTML email, but its often very hard work. -- Oded = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: HTML email question
On Wed, 28 Nov 2007 18:38:42 +0200, Hetz Ben Hamo wrote: No idea, but as others suggested - I'd do this with a P-language, not sh. Usually their builtin MIME etc. library functions are much easier to work with. Google for your favourite one plus 'mime mail tutorial' and I think you'll get some good intros. Yeah, I'm looking at PHP right now. Thanks for the help Didi, Oded, Lior :) I have written a bash script that sends emails and do mime attachments, but why invent the wheel when you can use something like mutt to send your mail (and attachments) from the command line ? mutt is available for Debian/Fedora (other Linuxes ?). See: http://www.cyberciti.biz/tips/sending-mail-with-attachment.html Disclaimer: I have not used mutt myself. Ehud. -- Ehud Karni Tel: +972-3-7966-561 /\ Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ GnuPG: 98EA398D http://www.keyserver.net/Better Safe Than Sorry = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]