Digiboy Posted June 28, 2013 Share Posted June 28, 2013 Hi guys, I am trying to send a html email via phpmail but keep receiving variables rather than data. $to = '[email protected]'; // subject $subject = 'title'; // message $message =' <html> <head> </head> <body> <p>How you have been effected: $effected</p> <p>URL: $url</p> <p>Company: $company</p> <p>Position: $position</p> <p>Email: $email</p> <p>Alternative Email: $alt_email</p> <p>Phone: $phone</p> <p>Address: $address</p> <p>City: $city</p> <p>Zip: $zip</p> <p>Country: $country</p> <p>Website: $website</p> <p>Signature: $signature</p> </body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Me <[email protected]>' . "\r\n"; mail($to, $subject, $message, $headers); I have also keep changing ' to " this is what i keep getting no matter what How you have been effected: $effected URL: $url Company: $company Position: $position Email: $email Alternative Email: $alt_email Phone: $phone Address: $address City: $city Zip: $zip Country: $country Website: $website Signature: $signature Any ideas? Thanks all in advance Link to comment https://forums.phpfreaks.com/topic/279665-php-mail/ Share on other sites More sharing options...
ginerjm Posted June 28, 2013 Share Posted June 28, 2013 Look up the use of the heredocs structure for assembling your html/var code block. Much better than including your vars in <? ?> php tags, which is what you are missing here. ex. $message=<<<heredocs <html> <body> <p>How you have been effected: $effected</p> <p>URL: $url</p> <p>Company: $company</p> <p>Position: $position</p> <p>Email: $email</p> <p>Alternative Email: $alt_email</p> <p>Phone: $phone</p> <p>Address: $address</p> <p>City: $city</p> <p>Zip: $zip</p> <p>Country: $country</p> <p>Website: $website</p> <p>Signature: $signature</p> </body> </html> heredocs; // in column 1!!!! Link to comment https://forums.phpfreaks.com/topic/279665-php-mail/#findComment-1438398 Share on other sites More sharing options...
marmstro Posted June 28, 2013 Share Posted June 28, 2013 Use a heredoc as ginerjm suggested or change the single quotes to double quotes on your $message variable assignment. Strings in single quotes don't do variable translation where strings in double quotes do. EX: $a = 'Bob'; echo 'Your name is $a' . "\n"; echo "Your name is $a" . "\n"; Output: Your name is $a Your name is Bob Link to comment https://forums.phpfreaks.com/topic/279665-php-mail/#findComment-1438411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.