RE: [PHP] variables in e-mail 2nd

From: Date: Fri, 17 Oct 2003 17:55:29 +0000
Subject: RE: [PHP] variables in e-mail 2nd
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166511@lists.php.net to get a copy of this message
What I do is make a PHP page/template with php variables in place. Then do something like this... $report = "path/to/mytemp.php"; $today = date(); ob_start(); include($report); $message = ob_get_contents(); ob_end_clean(); //echo $message; $to = "Daevid Vincent <daevid@daevid.com>"; //$to .= ", "."Daevid Vincent <daevid@daevid.com>"; // note the comma $headers = "MIME-Version: 1.0\r\n"; //$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: CRiMson <".WEBMASTER.">\r\n"; //$headers .= "Cc: sales@example.com\r\n"; //$headers .= "Bcc: president@example.com\r\n"; //$headers .= "Reply-To: ".$myname." <".$myreplyemail.">\r\n"; //$headers .= "X-Priority: 1\r\n"; //$headers .= "X-MSMail-Priority: High\r\n"; $headers .= "X-Mailer: CRiMson Server"; $subject = "my report"; // echo $message; mail($to, $subject, $message, $headers); That's the slick as shit solution. Then PHP will pull in your 'template' page and any variables or whatever are executed in the template $report, plus any that you have in your program (such as $today) are passed in to $message as well... Daevid Vincent http://daevid.com > -----Original Message----- > From: christian tischler [mailto:christian@tischler.co.uk] > Sent: Friday, October 17, 2003 7:10 AM > To: php-general@lists.php.net > Subject: [PHP] variables in e-mail 2nd > > I would like to use a form in a html page to pass the > variables to a php > page, which sends an mail including these variables. > > All I get in the mail though is a 1 rather than the string > that I put into > the form??? > > Can anyone help please! > > Some code I use.... > . > . > . > $messagepart1 = ' > <html> <head> <title>Free Subscription</title> </head> > <body> > <p>Somebody would like to have a free subscription!!!</p> '; > $messagepart2 = (echo $salutation); > $messagepart3 = ' </body> </html> '; > $message = $messagepart1.$messagepart2.$messagepart3; > . > . > . > mail(me@me.com, "Free Subscription Application", $message, $headers); > . > . > . > > The $salutation comes from the form and is handed over > correctly, but the > syntax for to display the value of the variable in the html > e-mail seems to > be the problem... > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#166511) next »