I use a great program called phpmailer, just look that up in a search , make sure to get the version that is the latest or these options below will not work with the older versions. Look for the one with the class.pop3 file and class.smtp. I will copy paste my code below, this code (as an excample) generates the full email with on the fly values and sends it. Currently I am adding a way to add comments prior to sending to the customer and addition images.
-----------------------------------
if (@$_REQUEST["a"]=="Email")
{
$userid = $_SESSION["UserID"];
$_SESSION["TEMPPRINT"] = 1;
//======upper body = master file customer info from order=======//
global $conn,$strTableName;
$str = "select from order_sales where Order_num='".$_SESSION[$strTableName."_masterkey1"]."'";
$hrs = db_query($str,$conn);
$data7 = db_fetch_array($hrs);
$str = "select from misc_zip_id_menu where ZIPID='".$data7["Billto_city"]."'";
$hrs = db_query($str,$conn);
$data8 = db_fetch_array($hrs);
$str = "select * from misc_zip_id_menu where ZIPID='".$data7["Shipto_city"]."'";
$hrs = db_query($str,$conn);
$data9 = db_fetch_array($hrs);
$str = "select firstname,lastname from employees where sessionid='".$data7["Employee_ID"]."'";
$hrs = db_query($str,$conn);
$data10 = db_fetch_array($hrs);
$str = "select pay_type_full from bill_pay_type where paytypeid='".$data7["Pay_type"]."'";
$hrs = db_query($str,$conn);
$data14 = db_fetch_array($hrs);
$data11["event_time_start"] = date("m/d/Y",$data7["event_time_start"]);
$data11["event_time_end"] = date("m/d/Y",$data7["event_time_end"]);
$data11["Cust_Chk1"] = 'XXXX-'.substr($data7["Cust_Chk1"],-4);
$str = "select CustSetupNam from order_surface_menu where CustSetupNum='".$data7["Surface_Setup"]."'";
$hrs = db_query($str,$conn);
$data12 = db_fetch_array($hrs);
$str = "select StatuesName from order_statues_menu where StatuesNumber='".$data7["Order_status"]."'";
$hrs = db_query($str,$conn);
$data13 = db_fetch_array($hrs);
//======email body top====//
//----removed.---------//
//---------".$data10["lastname"]."
//-------
//------
$body="<html>
<head>
<title>Invoicing</title>
</head>
<body>
<tr>
<td>
<h2>Your Invoice</h2>
<p>If you need further assistance with your order, please contact your sales representative <strong>".$data10["firstname"]."</strong></p>
<table width=\"600\" height=\"304\" border=\"0\">
<tr>
<td colspan=\"4\"><img src=\"images\amj4u1.JPG\" alt=\"****\" width=\"600\" height=\"90\"></td>
</tr>
<tr>
<td colspan=\"4\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-2\"> </td>
<td width=\"300\">Dates: ".$data11["event_time_end"]." - ".$data11["event_time_start"]."</td>
<td>P.O# : ".$data7["Billto_address2"]." INV# : ".$data7["Order_num"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-2\"> </td>
<td>Setup Time: ".$data7["event_time_delivery"]."</td>
<td>Pickup Time : ".$data7["event_time_pickup1"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-2\"> </td>
<td> </td>
<td> </td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-2\"> </td>
<td>Billing:</td>
<td >Location:</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-2\"> </td>
<td>".$data7["Billto_name"]." ".$data7["Billto_Lname"]."</td>
<td>".$data7["Shipto_name"]." ".$data7["Shipto_Lname"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-2\"> </td>
<td>".$data7["Billto_company"]."</td>
<td>".$data7["Shipto_company"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-2\"> </td>
<td>".$data7["Billto_address"]."</td>
<td >".$data7["Shipto_address"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-1\"> </td>
<td>".$data8["CityName"].", ".$data8["StateName"]." ".$data8["ZIPCode"]."</td>
<td>".$data9["CityName"].", ".$data9["StateName"]." ".$data9["ZIPCode"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"-1\"> </td>
<td>".$data7["Cust_email"]."</td>
<td>".$data11["Cust_Chk1"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"0\"> </td>
<td>".$data7["Phone_Home"]."</td>
<td>".$data14["pay_type_full"].", ".$data7["Cust_Date1"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"1\"> </td>
<td> </td>
<td> </td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"11\"> </td>
<td colspan=\"2\">Setup: ".$data12["CustSetupNam"]."</td>
<td width=\"2\"> </td>
</tr>
<tr>
<td width=\"72\" height=\"11\"> </td>
<td colspan=\"2\">Comments: ".$data7["Order_comments"]."</td>
<td width=\"2\"> </td>
</tr>
</table>
";
//==== file imaging background=\"images\invoice_r.gif\" =======//
//===== lower body array item listings for order======//
$str20 = "select from order_items where Order_num='".$_SESSION[$strTableName."_masterkey1"]."'";
$hrs20 = db_query($str20,$conn);
while($data20 = db_fetch_array($hrs20))
{
$str = "select ItemName from items where ItemID='".$data20["ItemID"]."'";
$hrs = db_query($str,$conn);
$data22 = db_fetch_array($hrs);
$str = "select Name from modual_panels where ItemID='".$data20["Moduals"]."'";
$hrs = db_query($str,$conn);
$data23 = db_fetch_array($hrs);
{
$body .="
<table width=\"596\" border=\"0\">
<tr>
<td width=\"62\"> </td>
<td width=\"33\"align=\"left\" height=\"21\">".$data20["Qty_order"]."</td>
<td width=\"85\"align=\"left\">".$data23["Name"]."</td>
<td width=\"290\"align=\"left\">".$data22["ItemName"]." ".$data20["Misc"]."</td>
<td align=\"right\">".$data20["Sub_total"]."</td>
<td width=\"50\"> </td>
</tr>
</table>
";
}}
//===== lower body final costs======//
$str21 = "select from order_sales where Order_num='".$_SESSION[$strTableName."_masterkey1"]."'";
$hrs21 = db_query($str21,$conn);
$data21 = db_fetch_array($hrs21);
$body .="
<table width=\"596\" border=\"0\">
<tr>
<td height=\"35\" align=\"right\" valign=\"bottom\">".$data21["Order_sub_total"]."</td>
<td width=\"50\"> </td>
</tr>
<tr>
<td height=\"21\" align=\"right\" valign=\"bottom\">- ".$data21["Discount"]."</td>
<td width=\"50\"> </td>
</tr>
<tr>
<td height=\"23\" align=\"right\" valign=\"bottom\">- ".$data21["Amount_down"]."</td>
<td width=\"50\"> </td>
</tr>
<tr>
<td height=\"29\" align=\"right\" valign=\"bottom\">".$data21["Order_total"]." </td>
<td width=\"50\"> </td>
</tr>
<tr>
<td height=\"100\"> </td>
<td width=\"50\"> </td>
</tr>
</table>
</body>
</html>";
//** Send email with new data ****
require_once($_SERVER['DOCUMENT_ROOT'].'/amoonjump4u_invoicing/output/include/phpmailer/class.phpmailer.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/amoonjump4u_invoicing/output/include/phpmailer/class.smtp.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.amjse.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.****"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "****"; // SMTP account username
$mail->Password = "n**"; // SMTP account password
$mail->SetFrom('info@****.com',$data10["firstname"]);
$mail->AddReplyTo('info@****.com,$data10["firstname"]);
$mail->Subject = " Invoice Order # ".$data7["Order_num"]."";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = $data7["Cust_email"];
$mail->AddAddress($address, "Invoicing");
$mail->AddAttachment("images/amj4u1.JPG"); // attachment
--------------------------
((edited out security info but you get the idea))
Finally, I left everything in so you can see how I did a full order with multiple items that would generate on the fly for the email to be sent. If you need any help, let me know. I use this code in the "list before event" and the button is....
// email
global $strTableName;
$str = "<INPUT class=button id=submit5 type=button value=\"Email\" name=submit5 onclick=\"var form = $('#frmAdmin1')[0];form.a.value='Email'; form.submit();\">";
echo $str;
- please note, this works on phprunner v5.2, I don't believe it will work on v5.3 and above , if I remember correctly they took out the or changed the a.value for arrays, you might have to change that.