Solved

Strange characters in emails sent by PHP

Posted on 2009-06-28
4
333 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

930 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

11 Experts available now in Live!

Get 1:1 Help Now