Welcome Guest, Not a member yet? Register   Sign In
Email issue - Q prep for header
#1

[eluser]FranckRR[/eluser]
Using utf-8 / html format with the Email library, a space is added on the subject

$this->CI->load->library('email');
$this->CI->email->set_mailtype("html");
$this->CI->email->from($fromAddress, $fromName);
$this->CI->email->to($toAddress);
$this->CI->email->reply_to($replyToAddress, $replyToName);
//Envoi d'un header supplémentaire avec le nom
//$this->CI->email->subject($subject); //Bug add space un the subject !!!
$this->CI->email->_headers['Subject']= $subject; //I had to do this UGLY thing !!!
$this->CI->email->message($bodyHTML);
$result=$this->CI->email->send($this->CI->config->item('msg_success'));

It seems that the issue is in Email.php:
public function subject($subject)
{
$subject = $this->_prep_q_encoding($subject);
$this->_set_header('Subject', $subject);
return $this;
}

In the final mail, I get
Subject: =?utf-8?Q?Chanel_et_RABE_REGIS_vous_invitent_=c3=a0_d=c3=a9couvrir_un_co ?= =?utf-8?Q?ntenu_chanel_makeup_confidential?=
Instead of :
Subject: =?utf-8?Q?Chanel_et_RABE_REGIS_vous_invitent_=c3=a0_d=c3=a9couvrir_un_contenu_chanel_makeup_confidential?=

It seems that it adds a new line after 75-7-5 chars
#2

[eluser]CroNiX[/eluser]
That's what the spec, RFC2822 Section 2.1.1, seems to call for.

Quote:There are two limits that this standard places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.

Then, in 2.2.3 it says:
Quote:Each header field is logically a single line of characters comprising
the field name, the colon, and the field body. For convenience
however, and to deal with the 998/78 character limitations per line,
the field body portion of a header field can be split into a multiple
line representation; this is called "folding". The general rule is

that wherever this standard allows for folding white space (not
simply WSP characters), a CRLF may be inserted before any WSP. For
example, the header field:

Subject: This is a test

can be represented as:

Subject: This
is a test
So, you are going against the standards and will probably have unpredictable results depending on email servers and the email client the end user is using. Not really a good idea if you want to better ensure delivery.
#3

[eluser]InsiteFX[/eluser]
I guess they can not read your signature CroNiX lol! Maybe you need to make it bigger...
#4

[eluser]CroNiX[/eluser]
There are size restrictions, or I would Smile
#5

[eluser]FranckRR[/eluser]
OK.
Next time code will be wrapped.

So you tell me that if I follow the standard, I'll have to live with a random space in my subject ... So this is it. End of discussion... Even it's stupid.

Just make a try. Use the Email library, encode in utf-8 french text in a subject longer that 100 chars and you will see how stupid is : the RFC or the CI implementation (I let you pick one)

Just for the records, I created a My_Email.php where for subject, I bypass the limitation (75)
#6

[eluser]CroNiX[/eluser]
Yes you can easily bypass it, but the receiving hosts email server might mangle it, classify it as spam or reject it outright and the end recipient might then not then receive it. Since you probably don't have control of what the receiving email server (or email reader) will do with email that doesn't conform to the standards, it would probably be best to ask yourself if it is absolutely necessary to have a subject line that long or if it can be shortened a bit.
#7

[eluser]FranckRR[/eluser]
So there's no solution ?

btw, I don't understand - probably due to my poor english understanding - MUST be less that 998 and SHOULD be less that 75
#8

[eluser]InsiteFX[/eluser]
Code:
$config['wrapchars'] = 76;  // Defaults is set to 76 Character count to wrap at.




Theme © iAndrew 2016 - Forum software by © MyBB