Bradillac Posted August 29, 2006 Share Posted August 29, 2006 This is my first post, so I feel obligated to give a little background. To make it short, basically I used to be an ASP developer and now I've jumped head first into PHP. The transition has been nothing but positive so far and I'm amazed at how many things transfer over.I do have one problem however. In ASP it's possible to, when sending an email with a script, link the script to another page. So basically the script takes from the server all the images and the html from that page and puts them in the email. So if I were to link it to a PHP page it would send the html version of it. Basically it's an easy way to make newsletters. The code looks something like this:<%Set myMail=CreateObject("CDO.Message")myMail.Subject="Sending email with CDO"myMail.From="mymail@mydomain.com"myMail.To="someone@somedomain.com"myMail.CreateMHTMLBody "http://www.w3schools.com/asp/" myMail.Sendset myMail=nothing%> I haven't found any scripts that do this similarly in PHP so.. I thought I'd come and exploit the friendly community here. Sorry to exploit you guys but, I know people here know what they're talking about... Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 29, 2006 Share Posted August 29, 2006 First, Welcome to PHPU will never think of using another Micro N Soft language againtry this[code]<?php$to = $email;$subject = "Email Subject"; $body = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\n"."<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"."<head>\n"."<title>The Title</title>\n"."</head>\n"".your message<br />\n"."Your Message\n"."</body>\n"."</html>\n"; $headers = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$headers .= 'To: '.$name.' <'.$email.'>,' . "\r\n"; //This is the TO name and Email$headers .= 'From: Name<email@domain.tld>' . "\r\n"; // This is YOUR name and emailif(mail($to, $subject, $body, $headers)){echo "Mail has been sent";}else{echo "Mail Failed";}?>[/code] Quote Link to comment Share on other sites More sharing options...
Bradillac Posted August 29, 2006 Author Share Posted August 29, 2006 That sends an HTML email all right. But the structure of what I'm trying to do goes like this:Send a form. That form adds all it's information to a database. There is a page (we'll call it newsletter.php) on the server that changes depending on the values stored in that database. After updating the form I need to send newsletter.php as html with all its images attached. The attached images part isn't as necessary because I can code the page to link to all images using full urls. Quote Link to comment Share on other sites More sharing options...
godzero Posted September 28, 2008 Share Posted September 28, 2008 I have a similar situation in that there's a PHP/HTML script which I want to be the body of the email. The previous poster didn't answer the question at all and I can't find the solution anywhere online. It's easy to do in Cold Fusion and ASP (and maybe others) so there should a way of doing it in PHP.Anyone got any ideas?Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.