Solved

Strange characters in emails sent by PHP

Posted on 2009-06-28
4
324 Views
Last Modified: 2012-05-07

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
Comment
Question by:BlueDriver
4 Comments
 
LVL 9

Assisted Solution

by:pmessana
pmessana earned 20 total points
Comment Utility
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
 
LVL 14

Assisted Solution

by:profya
profya earned 20 total points
Comment Utility
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
 
LVL 19

Expert Comment

by:Michael701
Comment Utility
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
 

Accepted Solution

by:
BlueDriver earned 0 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now