Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Junk appearing in variable via mail

    I have an e-mail script setup which outputs links depending on what options someone selects from a web form. Lately, I have been seeing junk output coming from my variable. For instance, one of the links that is outputted displays in the e-mail as:

    Code:
    http://files.bran!%0a+dtalexander.com/pdf/newsletter1.pdf
    It is inserting the '!%0a+' from somewhere and I cannot figure out where.

    I am using simple if statements to build a $msg variable:

    PHP Code:
    if ($item1==true) { $msg "http://files.brandtalexander.com/pdf/newsletter1.pdf"; }
    if (
    $item2==true) { $msg .= "http://files.brandtalexander.com/pdf/newsletter2.pdf"; } 
    and so on...

    My email code is:
    PHP Code:
                $headers "From: $email\r\n"
                
    $headers .= "MIME-Version: 1.0\r\n";
                
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
                
    mail($to$hostsub$hostmsg$headers); 
    I setup to have it echo the $msg and it is perfectly fine. The error only appears in the email itself. I have tested this with a variety of e-mail clients. What could be causing this? Thank you in advance.

  • #2
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I still cannot figure out why this is happening. Can anyone provide some insight? Thanks.

  • #3
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I was able to test this script on another server and had no issues at all. What could cause something like to happen all of a sudden? Did my host change a setting or some software? Any insight will be appreciated. Thank you.

  • #4
    New Coder
    Join Date
    Jul 2008
    Posts
    91
    Thanks
    4
    Thanked 9 Times in 9 Posts
    could be something with the php mail function. But i cant figure it out, it comes out ok here. Can you post the whole script and ill look over it a little more.
    Current Project: Nothing at the minute

  • #5
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts
    This is the code my form posts to. My host said there was an issue with some of the PHP extensions, but theyfixed them and the problem stills persists. You will find my code below (i took out all my form validation code to shorten it up). recipient, subject, domain and broch1, 2, etc are all passed from the originating form.

    PHP Code:
    <?php

    $path2pdf 
    $_POST['domain'] . "ebrochures/";
        
    //sends email to home
    $to $recipient;
    $date date("m/d/Y");
    $time date("h:i:s A");
    $hostsub "eBrochure request";
    $hostmsg "<strong>Feedback from website:</strong><br />
    Name: $name<br />
    Occupation: $occupation<br />
    Address: $address<br />
    City: $city<br />
    State: $state<br />
    Zip: $zip<br />
    Country: $country<br />
    E-Mail: $email<br />
    Phone: $phone<br /><br />
    Comments: $comments <br /><br />
    <b>Requested Brochures:</b> <br />"
    ;
                
    $brochmsg  =($_POST['broch1'])?"<a href=\"".$path2pdf."ebrochure_01.pdf\">eBrochure #01</a><br>":"";
    $brochmsg .=($_POST['broch2'])?"<a href=\"".$path2pdf."ebrochure_02.pdf\">eBrochure #02</a><br>":"";
    $brochmsg .=($_POST['broch3'])?"<a href=\"".$path2pdf."ebrochure_03.pdf\">eBrochure #03</a><br>":"";

    //combine host and brochure message
    $hostmsg .= $brochmsg;
    $hostmsg  stripslashes($hostmsg);

    $headers  "From: $email\r\n"
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    mail($to$hostsub$hostmsg$headers);

    //sends email to user
    $to $email;
    $hostmsg "";
    $hostmsg "Thank you $name for requesting our eBrochures! Below you will find the links directing you to the PDF versions of our eBrochures that you requested.<br /><br />";
    $hostmsg .= "<b>eBrochures:</b><br />";
    $hostmsg .= $brochmsg;
    $hostmsg  stripslashes($hostmsg);

    $headers "From: $recipient\r\n"
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    mail($to$subject$hostmsg$headers);
    header("Location: ".$_SERVER['PHP_SELF']."?action=sent");
            
    ?>


  •  

    Posting Permissions

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