Problem with '&' charachter.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zamuel
    New Member
    • Sep 2006
    • 42

    #16
    That is correct! I am able to echo before sending, but the message body is empty every time.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #17
      There's a couple of possibilities here. The first idea is that the command line arguments passed to sendmail aren't escaped, so the shell sees the ampersand as the "run in background" operator instead of part of the message. That's not a good thing.

      If the email breaks when the body contains quotes, a pipe ("|") or greater than as well, that's a good indication of what's going on.

      The other alternative is that sendmail itself is doing something wrong with the ampersand.

      Ultimately, my recommendation would be to use a class such as PHPMailer or Swift Mailer instead of relying on sendmail. Both PHPMailer and Swift Mailer implement SMTP independently of sendmail for better compatibility.

      Comment

      • nathj
        Recognized Expert Contributor
        • May 2007
        • 937

        #18
        Originally posted by pbmods
        There's a couple of possibilities here. The first idea is that the command line arguments passed to sendmail aren't escaped, so the shell sees the ampersand as the "run in background" operator instead of part of the message. That's not a good thing.

        If the email breaks when the body contains quotes, a pipe ("|") or greater than as well, that's a good indication of what's going on.
        Well I've learnt something there. This is what I was trying to get at but didn't know for sure, so with your input I have discovered something new.

        I love this forum.
        nathj

        Comment

        • zamuel
          New Member
          • Sep 2006
          • 42

          #19
          Ok, I have discovered few other errors. Additionally sign '<' also causes same behavior. Also when I add " or ' the massage becomes \' or \". I am starting to suspect the XML part for the source of the error.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #20
            Does '>' do anything untoward as well, or is it just '<' and '&'?

            Check your Apache error log and see if anything fishy is going on.

            Comment

            • nathj
              Recognized Expert Contributor
              • May 2007
              • 937

              #21
              Originally posted by zamuel
              Ok, I have discovered few other errors. Additionally sign '<' also causes same behavior. Also when I add " or ' the massage becomes \' or \". I am starting to suspect the XML part for the source of the error.
              The presence of \ is simpy mail() escaping the quotes. If you want rid of those simply use stripslashes() and that will sort you out.

              cheers
              nathj

              Comment

              • zamuel
                New Member
                • Sep 2006
                • 42

                #22
                So, I decided to replace those problematic signs (<, & ). Couldn't come up with other solution. And nathj, thanks for the tip for stripslashes() function.

                Thanks for all the help on this case.

                Comment

                Working...