SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mail Converting To Hex...How do I stop it?

    The other day, my CMS sent out a daily alert to my e-mail list.

    In the subject it read:
    Dr. Dre and Eminem Face $10 Mil Copyright Suit
    But in the actual body of the message it read:
    Dr. Dre and Eminem Face #36; 10 Mil Copyright Suit
    Then I looked back and noticed that it's always done that since I wrote the program...I never noticed it. Any ideas what I should do? I have pasted the e-mail that I've been using below:

    Code:
    From: SOHH Alert <alerts-list@sohh.com>
    Reply-To: alerts-list@sohh.com
    MIME-Version: 1.0
    Content-Type: text/plain; charset=iso-8859-1
    X-Mailer: SOHH Alert - PHP / 4.1.2
    Thanks for reading.

    one
    Last edited by ibeblunt; Jul 18, 2003 at 10:58.
    <///////~

    www.sohh.com

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't understand, the code you posted above only outputs the from and reply-to headers, not the message body.

    What's the code for the message body?
    and where's the HEX?
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assumed the problem might be with the message headers. But ok, since you asked...

    Ah, you can't see the hex because vBulletin parses it...Lemme edit the first post...there fixed...

    Anyway, the code for the message body is pulled from the database and put into an array. The array would be $contentheadline. I use this for $mail_subject AND $mail_body...It doesn't bother the ampersand as a subject, only in the body.

    The code is:

    PHP Code:
    $mail_to "steven@sohh.com";

    $mail_subject $article_ARRAY['contentheadline'];

    $mail_headers   =    "Bcc: " $bcc_email "\r\n";
    $mail_headers   .=    "From: SOHH Alert <alerts-list@sohh.com>\r\n";
    $mail_headers   .=    "Reply-To: [email]alerts-list@sohh.com[/email]\r\n";
    $mail_headers   .=    "MIME-Version: 1.0\r\n";
    $mail_headers   .=    "Content-Type: text/plain; charset=iso-8859-1\r\n";
    $mail_headers   .=    "X-Mailer: SOHH Alert - PHP / " phpversion() . "\r\n";

    $mail_body $article_ARRAY['contentheadline'];

    mail($mail_to,$mail_subject,wordwrap(stripslashes($mail_body),69),$mail_headers); 
    Last edited by ibeblunt; Jul 18, 2003 at 10:10.
    <///////~

    www.sohh.com

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, I still can't see the hex, but if you were to
    PHP Code:
    echo $mail_subject
    echo 
    $mail_body
    echo 
    wordwrap(stripslashes($mail_body), 69); 
    Would you still see the same phenomenon? On which ones?
    My name is Steve, and I'm a super-villian.

  5. #5
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lieut_data
    Unfortunately, I still can't see the hex, but if you were to
    PHP Code:
    echo $mail_subject
    echo 
    $mail_body
    echo 
    wordwrap(stripslashes($mail_body), 69); 
    Would you still see the same phenomenon? On which ones?
    Echoing to the screen, you won't see it. The browser will translate it...Only when it comes in the mail.

    Basically in the second example in my first post the ampersand had been converted to & # 3 6 ; (but altogether...vBulletin keeps converting it...so I have to put spaces inbetween it.)
    <///////~

    www.sohh.com

  6. #6
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There you should be able to see it now...
    <///////~

    www.sohh.com

  7. #7
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I just ran that echo test myself, and didn't notice anything unusual...

    So we know it's getting converted in the mail function.

    Out of curiosity, could it be that the $article_ARRAY['contentheadline']; have the "$" encoded as "&#36"? Then it's the fact the subject line *is* converting it correctly, but the message body is not? (?!?)
    My name is Steve, and I'm a super-villian.

  8. #8
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lieut_data
    Yeah, I just ran that echo test myself, and didn't notice anything unusual...

    So we know it's getting converted in the mail function.

    Out of curiosity, could it be that the $article_ARRAY['contentheadline']; have the "$" encoded as "&#36"? Then it's the fact the subject line *is* converting it correctly, but the message body is not? (?!?)
    No, the subject line is saved in the database as Dr. Dre and Eminem Face $10 Mil Copyright Suit. It is pulled AS IS. Try this...using PHP send yourself an e-mail with the subject 'te$t'...I know what I get. What do you get?
    <///////~

    www.sohh.com

  9. #9
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've given up on this.

    I solved it by just doing a simple:

    ereg_replace()

    I really wanted to find a better way to do it, but...

    Thanks...
    <///////~

    www.sohh.com

  10. #10
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hadn't yet had a chance to test this as I don't have my SMTP server installed... but I agree, twould be better to find the actual problem...

    If I ever *do* get it installed, and run some tests, I'll be sure to post back
    My name is Steve, and I'm a super-villian.

  11. #11
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lieut_data
    I hadn't yet had a chance to test this as I don't have my SMTP server installed... but I agree, twould be better to find the actual problem...

    If I ever *do* get it installed, and run some tests, I'll be sure to post back
    You know, I forgot to tell you....

    I use PHPLIB Templates for my mass mails. So when I tested it without PHPLIB, it worked. I didn't think PHPLIB would make a difference but it does.

    I'm considering switching to Smarty.
    <///////~

    www.sohh.com

  12. #12
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can rest easy knowing you found the problem

    I've never been much for templates, though... always seemed too much of a bother than just coding it manually...

    How's your experience been?
    My name is Steve, and I'm a super-villian.

  13. #13
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lieut_data
    I can rest easy knowing you found the problem

    I've never been much for templates, though... always seemed too much of a bother than just coding it manually...

    How's your experience been?
    Depends...For me, I have my common functions which grab content and puts them into arrays and stuff.

    Then I just code my template page and it spits it out.

    I hate having to wade through HTML and PHP code. It's cleaner and if I ever get a partner, one of us could code, while the other designed.
    <///////~

    www.sohh.com

  14. #14
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good point, I'll have to look at templates more closely on my next project :-)
    My name is Steve, and I'm a super-villian.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •