CodeIgniter Forums
Obfuscated Email Subject Issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Obfuscated Email Subject Issue (/showthread.php?tid=30246)

Pages: 1 2 3


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]whobutsb[/eluser]
I'm writing an emailing class for a surveying application i'm coding. Whenever I add the subject variable in to $this->CI->email->subject(); method it obfuscates the subject.

Here is my code:
Code:
$this->CI->email->from('[email protected]', 'Me');
        $this->CI->email->reply_to('[email protected]', 'Me');  
        
        $this->CI->email->to('[email protected]');
    
        $this->CI->email->subject($distribution->emailSubject);
        $this->CI->email->message($distribution->emailBody);

$this->CI->email->send();

The variable $distribution->emailSubject should look like "How was your meal? Let us know and earn 20 points!". But in my subject line of my email client it looks like: "=?utf-8?Q?_How_was_your_meal=3f__Let_us_know_and_earn_20_Points_on_Fare_ X-Sender:"

Has anyone run into a situation like this?


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]WanWizard[/eluser]
This is how it should be. It tells the mail client receiving the email that the subject text uses utf-8 encoding, as per RFC 1342.


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]whobutsb[/eluser]
Now when I type in the subject directly in to the email->subject method, the subject line looks fine. Why would it look different if I'm putting in a variable that says the same exact thing?


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]WanWizard[/eluser]
The subject will always be q-encoded, in case it contains non-ascii characters (7bit), an underscore, an equals sign, or a question mark.

So "How was your meal? Let us know and earn 20 points!" will always be encoded, no matter how you pass it to $this->email->subject().

from the Email library:
Code:
function subject($subject)
{
    $subject = $this->_prep_q_encoding($subject);
    $this->_set_header('Subject', $subject);
}



Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]whobutsb[/eluser]
I see, but why would it look differently from if I just write it in directly? Is there any way for me to fix my error?


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]WanWizard[/eluser]
What do you mean by 'write it in directly'?

Code:
$this->email->subject('How was your meal?  Let us know and earn 20 points!');
is exactly the same as
Code:
$var = 'How was your meal?  Let us know and earn 20 points!';
$this->email->subject($var);



Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]whobutsb[/eluser]
Correct, but when I use the variable method. The subject line gets printed as: =?utf-8?Q?_How_was_your_meal=3f__Let_us_know_and_earn_20_Points_on_Fare_ X-Sender:


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]WanWizard[/eluser]
Yes, as it should be. The only thing that puzzles me is the 'X-Sender:' at the end, which should be on the next line.

Where do you get this subject line from? From the header of your mail client? Which mail client?


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]whobutsb[/eluser]
This is the exact subject line from Apple Mail:
=?utf-8?Q?_How_was_your_meal=3f__Let_us_know_and_earn_20_Points_on_Fare_ X-Sender: [email protected]

(I removed the actual email address in the subject line). If you are interested in me forwarding you the message, just send me a quick email to (my forum username)@gmail.com, that way I can send you all the header information.

Thank you for your help btw.


Obfuscated Email Subject Issue - El Forum - 05-07-2010

[eluser]WanWizard[/eluser]
Sounds more like an issue with your email client. What happens if you send that exact same email to your gmail account?

If I send an email out with that subject line to the mail systems I have here (imap/squirrelmail & exchange 2010/Outlook 2010), both show the header in q-encoding, and display the subject properly.

see if
Code:
$this-email->newline  = "\r\n";
will help...