Solved

Strange characters in emails sent by PHP

Posted on 2009-06-28
4
345 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
ID: 24731922
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
ID: 24731991
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
ID: 24732683
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
ID: 24735197
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP & MySQL - Rounding Results from a Select Query 3 25
php string detection problem 7 34
mysql date time 14 31
Is there a simpler dropbox system? 10 22
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

810 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