Jump to content

creating a html email from php database info


wmguk

Recommended Posts

Hi guys,

 

This might be so dumb, but is there anyway to create an html email from some php info?

 

<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="80" align="left" valign="top" background="http://www.website.co.uk/images/top.jpg"><p> </p>    </td>
  </tr>
  <tr>
    <td align="left" valign="top" background="http://www.website.co.uk//images/middle.jpg">
<table width="800" border="0" cellspacing="0" cellpadding="0">
     <tr>
       <td width="20"> </td>
       <td class="main">
         <p>Dear 
	 <?php
	 if ($groom_firstname == 'X') 
{  
  echo $bride_firstname ;
} 
  else
{
  echo $bride_firstname " and " $groom_firstname "," ; 
}
?></p>
         <p>We are please to announce that your album has been made live now.</p>
         <p>Please click <a href="http://website.co.uk/emailgallery.php?login=<? echo $login ; ?>">HERE</a> to view your album. </p>
         <p>You can also now tell all your family and friends about your new album by clicking HERE. </p></td>
   <td width="20"> </td>
 </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" valign="top" background="http://www.website.co.uk/images/bottom.jpg"> </td>
  </tr>
  <tr>
    <td align="left" valign="top"><blockquote>
    </blockquote></td>
  </tr>
</table>

Link to comment
Share on other sites

I dont know how to make the actual email, is it just

 

<?php
//Make Connection

include "http://www.website.co.uk/scripts/connection.php"; 
if (!$con) 
{ 
 die( 'Could not connect: ' . mysql_error() ); 
  }
mysql_select_db($db, $con); 

$result = mysql_query("SELECT * FROM album WHERE username= $user");
?>

 

how do i get the info from the database though?

 

there will only be one row of info to use...

 

only a few fields

 

<?php
# -=-=-=- MIME BOUNDARY

$mime_boundary = "----Your_Company_Name----".md5(time());

# -=-=-=- MAIL HEADERS

$to = "$email";
$subject = "This text will display in the email's Subject Field";

$headers = "From: Our Company <company@ourcompany.com>\n";
$headers .= "Reply-To: Our Company <company@ourcompany.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

# -=-=-=- HTML EMAIL PART

$message .= "--$mime_boundary\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";

$message .= "<html>\n";
$message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:14px; color:#666666;\">\n"; 
$message .= "<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='80' align='left' valign='top' background='http://www.website.co.uk/images/top.jpg'><p> </p></td></tr><tr><td align='left' valign='top' background='http://www.website.co.uk//images/middle.jpg'>";
$message .= "<table width='800' border='0' cellspacing='0' cellpadding='0'><tr><td width='20'> </td>";
$message .= "<td class='main'><p>Dear ";
$message .= "if ($groom_firstname == 'X') {  ";
$message .= "echo $bride_firstname ; } ";
$message .= "else { ";
$message .= "echo $bride_firstname ' and ' $groom_firstname ',' ; }</p>";
$message .= "<p>We are please to announce that your album has been made live now.</p>";
$message .= "<p>Please click <a href='http://website.co.uk/emailgallery.php?login=$login'>HERE</a> to view your album. </p>";
$message .= "<p>You can also now tell all your family and friends about your new album by clicking HERE. </p></td><td width='20'> </td></tr></table></td></tr>";
$message .= "<tr><td align='left' valign='top' background='http://www.website.co.uk/images/bottom.jpg'> </td></tr></table>";
$message .= "</body>\n";
$message .= "</html>\n";

# -=-=-=- FINAL BOUNDARY

$message .= "--$mime_boundary--\n\n";

# -=-=-=- SEND MAIL

$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed"; 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.