How to send mail to someones e-mail address?

PHP: Send mail using email address in a variable? 10 points for best answer?

  • I'm trying to do this - mail('[email protected] , $contactemail', 'Booking Confirmation', $message, $headers); Everything is working BUT $contactemail. as you can see, the first email address is fixed, and the mail goes there, but the second should be going to an email address stored in a variable. When sent to the fixed address, it says it was also sent to [email protected] (the variable has not been replaced).Why is this not working??? Thanks in advance.

  • Answer:

    If you want to expand variable names in a string like that, you need to enclose your string in "double quotes". Variable expansion is not performed on string literals that are enclosed in 'single quotes'.

Matthew at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

PUt the recipients in a string, use the string in the mail function - good example below, the PHP manual.

Control Muncher

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.