Solved

PHP EMail - Headers not working (Reply-To etc.)

Posted on 2009-04-14
3
915 Views
Last Modified: 2013-12-17
Can anybody tell me why this does not work ...

      $headers =      'From: ' . $row_webdata['billing_email_address'] . "\r\n" .
                        'reply-to: ' . $row_webdata['contact_email_address'] . "\r\n" .
                        'bcc: ' . $row_webdata['copy_invoices']. "\r\n" .
                        'cc: ' . $row_webdata['info']. "\r\n" .
                         'X-Mailer: PHP/' . phpversion();

The e-mail goes to the 'to' address quite happily but not to the 'cc' address (although that appears on the e-mail headers). The 'reply-to & 'bcc' do not seem to make any impact on this e-mail mstatement they neither appear on the email header nor result in an email? I have played around with the case, i.e. Reply-To' etc. but none of it seems to make any difference.

Thanks.
Patrick.
0
Comment
Question by:me_patrick
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
Chris_Gralike earned 500 total points
ID: 24137074
There are issues with older php versions running on Windows.  They use their own implementation to talk to the mailserver. As far as i know these are working fine in later versions. Also make sure the header is constructed correctly.

$header = "From:".$row_webdata[billing_email_address]."\r\n";
$header .= "reply-to:". $row_webdata['contact_email_address']."\r\n";
$header .= "bcc:".$row_webdata['copy_invoices']."\r\n";  < contained a typo.
$header .= "cc:".$row_webdata['info']."\r\n"; <contained a typo.
$header .= "X-Mailer:PHP". phpversion();

Im not sure how the values of the vars look, but make sure they also have the correct syntax :)
Please try the code above and let me know.

Rgrds,

0
 

Author Closing Comment

by:me_patrick
ID: 31575387
Hi Chris,

Thanks a lot for taking the time to respond and sorry for taking so long to get back to but I got distracted on something else ... anyway I'm back and blimey ... you've only gone and done it!

I can't however see what you've done ... I'm looking and looking and I can't see the difference between what I had and what you suggested (I can't even see the typo's that you refer to)??

Anyway I re-jigged my headers into several statements rather than one and it worked ...  oh dear ... I've just looked again and I'm afraid it was all just a school boy error on my part ... my select statement was only pulling back certain web address fields and not all, so my cc and reply to addresses were not available .... D'oh!

Anyway - great all sorted and thanks again.
P.
0
 
LVL 10

Expert Comment

by:Chris_Gralike
ID: 24249715
Sorry, I did not notice at first that it was supposed to be one long line of text. Noticed it after I read the line again, and thought for readability ill just leave it like this.

Happy you sorted the problem though.

Rgrds,

0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
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…

808 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