Jump to content


Photo

Email HTML page.


  • Please log in to reply
3 replies to this topic

#1 Bradillac

Bradillac
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 August 2006 - 02:55 PM

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.Send
set 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...

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 29 August 2006 - 03:01 PM

First, Welcome to PHP
U will never think of using another Micro N Soft language again
try this

<?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 email

if(mail($to, $subject, $body, $headers)){
echo "Mail has been sent";
}else{
echo "Mail Failed";
}

?>

Tell me the problem, I will try tell you the solution

#3 Bradillac

Bradillac
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 August 2006 - 03:16 PM

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. 


#4 godzero

godzero
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 28 September 2008 - 04:49 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users