Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

Strange characters in emails sent by PHP


I have using PHP to send an email.  The email is received, but I get what's below; note the 'greater than' symbol before jim's email address. Why is that there?

Dear Dave,

Please let me know as soon as you get back.

>From : jim@whatever.com

$msg .= "\n\nDear Dave\n\nPlease let me know as soon as you get back.\n\nFrom : $sender_email\n\n"; 
$ipaddress = getenv(REMOTE_ADDR);
$msg .= "Logged IP Address:$ipaddress\n\n"; 
 
$recipient = "info@whatever.com"; 
$subject = "Keep me informed"; 
$mailheaders = "From: $sender_email\n\n"; 
 
mail($recipient, $subject, $msg, $mailheaders);

Open in new window

0
BlueDriver
Asked:
BlueDriver
3 Solutions
 
pmessanaCommented:
Can you post the entire source of the received email?  Go into the email and 'view source' and paste it here.  Also, are you setting more headers or if you run exactly what you have included it gives this weight greater than?  I am thinking that is something wrong in the header.

I ran the exact code above on my server and it did not return anything out of the ordinary.


~~~~~~~~~
Dear Dave

Please let me know as soon as you get back.

From : peter@xxxxxx.com

Logged IP Address:24.174.xx.xx

~~~~~~~~~~~~
0
 
profyaCommented:
We do need to see all code involved in the process, however, there are possible problems from the following:
1) $sender_email is not included in the code submitted.
2) $msg .= "\n\nDear Dave\n\nPlease....." concatenated, I think it should start with:
$msg="........." not $msg.="............"
3) getenv(REMOTE_ADDR); may cause a notice, the best is to write it as
getenv("REMOTE_ADDR");
 I hope this helps
0
 
Michael701Commented:
try adding some spaces so you don't have blank lines. it may be a response from the smtp server.

$msg .= " \n \nDear Dave\n \nPlease let me know as soon as you get back.\n \nFrom : $sender_email\n \n";
0
 
BlueDriverAuthor Commented:
Dear all,

thank you for your answers. None seemed to fix the issue but eventually I changed the word 'From' to 'sender' and the problem stopped.... It seemed my 'helpful' mail software (TheBat!) automatically added the > symbol to the line, assuming it was a quote.... Arghhh !

Sorry to have troubled you.  Thanks.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now