Sign In  |  Cart  |  Join Now

Form mail encoding

April 16, 2009
Hello!
When receiving the mail that notify me a form submission I get a human unreadable BASE64 encoded text.
I've tested to send a simple mail with phpmail and it arrives correctly.
I report a mail that came from my Concrete5 site:
<?php  
Content
-typetext/plaincharset=UTF-8
From
: <!!MY_REMOVED_E-MAIL_ADDRESS!!>
Mime-Version1.0
Content
-Transfer-EncodingBASE64
CkUnIHN0YXRvIGludmlhdG8gaWwgZm9ybSBSaWNoaWVzdGEgaW5mb3JtYXppb25pIHRyYW1pdGUg
aWwgdHVvIHNpdG8gQ29uY3JldGU1LgoKRW1haWwgcGVyc29uYWxlDQpoZW5yaWsuc296em
ETC
ETCETC (Ive removed the other base64 lines
 
?>


The simple script I've successfully used to test phpmail was this:
<?php
error_reporting
(E_ALL);
$mail_from="postmaster@!!MY_REMOVED_DOMAIN!!";
$mail_subject="Testing e-mail";
$mail_text="Questa è una e-Mail di test inviata dal servizio Hosting di Aruba.it per la verifica del corretto funzionamento di PHP mail()function .
Aruba.it"
;
$mail_to="!!MY_REMOVED_E-MAIL!!";
if( 
mail$mail_to$mail_subject$mail_text"From: {$mail_from}\r\n" ) ) {
    echo 
"Mail inviata correttamente !<br><br>Questo di seguito è il codice sorgente usato per l'invio della mail:<br><br>";
    
highlight_file($_SERVER["SCRIPT_FILENAME"]);
    
unlink($_SERVER["SCRIPT_FILENAME"]);
} else
    echo 
"<br><br>Recapito e-Mail fallito!";
?>


Can anyone give me an advice on how to fix this?
Thank you,
Henrik

No one? :(

Apr 24, 2009 at 7:07 PM
Are you sure you don't know about this issue? Should I disable the mail notify? Is it not working?
 

Me too

May 11, 2009 at 3:31 AM
I am experiencing this issue right now.
With v5.2.x everything was fine.
I also tried disabling the localization file.
 

Same here

May 11, 2009 at 4:19 AM
Yeah got that here to now and notified the IT department here. What his problem seemed to be was that the main email server doesn't know BASE64 decoding, he rerouted it to the INTRANET server and that works. Temporary solution tho...
 

tried the mail helper yet?

May 11, 2009 at 8:49 AM
simple example
<?php  
$mh 
Loader::helper('mail');
$mh->to('destination@email.com');
$mh->from('from@email.com''from name');
$mh->setSubject('the subject');
$mh->setBody("line one\nline two");
@
$mh->send();
 
?>


ps: that's from memory, double check the api to be sure
 

One more

May 11, 2009 at 3:39 PM
I am having the same problem: with outlook 2007 i get a mix of characters, but reading it on my mobile phone it shows up correctly.

Is it a problem of outlook or the way it is sent?

I cant fint any settings for sending email in concrete, or is there?

Hope to fix this asap!!!
Thanks for any help
 

SOLVED!!!

May 12, 2009 at 11:55 AM
I debugged the incriminated file: mail.php in concrete/helpers directory and SOLVED the problem!
I've found it by analyzing the raw content of the mail that I've got (following a small piece for understanding):
<?php  
Subject
Richiesta informazioni Conferma form
MIME
-Version1.0
Content
-typetext/plaincharset=UTF-8
From
: ************ (my mail)
Mime-Version1.0
Content
-Transfer-EncodingBASE64
 ?>


Now we know that in SMTP protocol two consecutive CRLF determine the begin of the mail body.
The problem is around "Content-type: text/plain; charset=UTF-8", watching in hex i've found that sequence: "0d 0d 0a".

That means that after "MIME-Version: 1.0" the real mail started, resulting in loosing the following headers lines (that you could see in the body...)

So i changed the line 122 and 123 of mail.php removing "\r" leaving only new line "\n", so the resulting of those two lines is the following:
<?php  
$header  
"MIME-Version: 1.0\n";
$header .= "Content-type: text/plain; charset=" APP_CHARSET "\n";
 
?>


Now I have only "0D 0A" and it works fine!

While watching I've found another bug... at line 129 there is:
<?php  
if (function_exists('mb_encode_mimeheade')) {
 
?>


...but there is a typo at the end of the string, it should be 'mb_encode_mimeheader'.

I've informed the admin about that so that it can be fixed in the next release.
 

misspell

May 12, 2009 at 12:06 PM
<?php  if (function_exist ('mb_encode_mimeheade')) { ?>

This maybe why the mail has been converted to BASE64

Also... in addition to your misspell fix, sometime... you may have to set the php.ini to be like this

PHP.INI Setting

<?php  default_charset UTF-8
mbstring
.language neutral
mbstring
.internal_encoding UTF-8
mbstring
.http_input auto
mbstring
.http_output UTF-8 ?>

or

.htaccess
<?php  php_value mbstring.language neutral
php_value mbstring
.internal_encoding UTF-8
php_value mbstring
.http_input auto
php_value mbstring
.http_output UTF-8 ?>


This is how I solved my mail encoding for Japanese.

But thank you for finding the mispell~!
 

But the double CR?

May 12, 2009 at 12:26 PM
Hm, that maybe can fix the encoding (I'm a real newbie of php), but the double CR? Does it work for you? Don't you receive a mail with a body that begin as the following?
<?php  
Content
-typetext/plaincharset=UTF-8
From
: <mail inserted in form>
Mime-Version1.0
Content
-Transfer-EncodingBASE64
<the form content>
 
?>

Plus it comes from an anonymous user...
If you fix the header it comes from the mail that the user inserted in form and no wrong header at the beginning of the form.
Can you check how are your mails?
 

My mail header

May 12, 2009 at 12:52 PM
Here is my mail header
<?php  FromXXXXXX@concrete5-japan.org
Date
May 112009 5:43:45 PM PDT
To
XXXXXXX@concrete5-japan.org
Mime
-Version1.0
Mime
-Version1.0
Content
-Typetext/plaincharset=UTF-8
Content
-Transfer-EncodingBASE64 ?>


And I'm using Gmail & Apple Mail. And it's working fine without modifying the mail.php misspell.
 

Hm...

May 12, 2009 at 1:16 PM
However the body is still encoded in BASE64 and you have too "Mime-Version: 1.0" twice (I didn't mention that but me too).
I'll test your solution to see the effects returning to standard mail.php.
However the problem, I believe, was not the mispelling, but the "\r\n" that becomed "\n".
Can you check if you have "0D 0D 0A" or "0D 0A" before and after "Contet-type: text/plain; charset=UTF-8"?
 

Yep

May 12, 2009 at 1:19 PM
Yeah...

For me, it's working fine... so I let "Mime-Version: 1.0" to repeat.

And I decided to carry on my life to the next level :p

But yeah... we may want to fix this.

Sorry.. I have a presentation tomorrow... I'll catch this up later.
 

ahah :D

May 12, 2009 at 1:42 PM
Ok, ok, it's true, who cares about that :) My goal was to receive a readable mail and to help bugfixing Concrete5 ;)
Good luck for your presentation!
 

OK... either mb_send or mb_encode_mimeheader

May 16, 2009 at 11:06 PM
So it was good that they misspelled "mb_encode_mimeheader".

I learned that "mb_encode_mimeheader" should only be used if there is no mb_send.

So if you are sending mbstring via regular mail or send_mail, you need to do mb_encode_mimeheader for mail subject.

But mb_send alaready does its job.

There is nothing to do with your topic... but thanks to your finding.... it got my attention. Thanks energywave!
 

Yeeeeh

May 13, 2009 at 3:20 AM
That solved it for me too.

Thanks energywave!
 

contact form

Jun 26, 2009 at 10:44 AM
I got that 'gibberish' also. Taking off they '\r' worked. I tried the .htaccess method, but that did'nt make any differance for me. I use Thunderbird for my pop mail.
 

contact form

Jun 26, 2009 at 10:48 AM
Where does one make additional tweaks like 'Reply to', the body text etc ... "There has been a submission of..."?
 

WOOT!

Jul 08, 2009 at 1:02 AM
Hi i'm being playing around ALL morning trying to fix this. Thank you it works now:-)!
 
 

Hot Spots...

Forums | BugsPartners | Contact | Blog

Search site