Solved

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

Posted on 2009-04-14
3
914 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this video we show how to create a mailbox database 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 Servers >> Data‚Ķ
To show how to generate a certificate request 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 Servers >> Certificates‚Ķ

809 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