Question:
PHP: Send mail using email address in a variable? 10 points for best answer?
?
2012-03-11 08:40:41 UTC
I'm trying to do this -

mail('support@mywebsite.com , $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 $contactemail@myhost.com (the variable has not been replaced).Why is this not working???

Thanks in advance.
Three answers:
Silent
2012-03-11 08:46:05 UTC
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'.
Control Muncher
2012-03-11 09:01:53 UTC
PUt the recipients in a string, use the string in the mail function - good example below, the PHP manual.
guerin
2016-12-10 10:40:11 UTC
You write the recipient's finished email address interior the "To:" area. you do no longer choose the "Cc:" area except you choose to deliver a replica to somebody (or your self). "concern" is in spite of you choose it to assert. attempt sending an email to somebody else first, and not your self. perhaps you omitted an significant area of your guy or woman email address (and in basic terms despatched it on your username?) i assume you're kidding, via fact signing up for Yahoo solutions is lots extra complicated than determining a thank you to deliver an email.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...