Sending email with PHP
Posted: Fri Nov 11, 2005 10:16 am
I had asked someone to write a program for me in PHP. He setup an email class to send emails. It works great in the one program he set up to send an invoice:
But when I try to send an email on my contact me page, (I don't want the customer order etc on a contact page) it doesn't work:
Here is the email class he wrote:
The guy that wrote the program for me is too busy to help anymore.... and I am stuck! Any idea what is wrong when I try to send an email in my contact page?
Thanks for any help!
Code: Select all
C_Email::email_html($o_c->getSiteemail(),$o_c->getSiteemail(),$message,"New Order Placed At ".$o_c->getSitename(),$user_id);
C_Email::email_html("$order[customer_bill_name]" ,"$order[customer_email]",$message,"Your Receipt From ".$o_c->getSitename(),$user_id);Code: Select all
C_Email::email_html2($contactname,$contactemail,$message,$subject,$myname',$myemail,$myreplyemail,$from);Code: Select all
<?
// inclue in document head
// create a new object $o_email = new e_mail; syntax
// ue it syntax $o_email->function($value);
class C_Email
{
function my_mail($to, $subject, $message, $headers,$from)
{
require_once("GLOBAL/smtp.php");
$smtp=new smtp_class;
$smtp->direct_delivery=0; /* Set to 1 to deliver directly to the recepient SMTP server */
$smtp->timeout=10; /* Set to the number of seconds wait for a successful connection to the SMTP server */
$smtp->data_timeout=0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server.
Set to 0 to use the same defined in the timeout variable */
$smtp->debug=0; /* Set to 1 to output the communication with the SMTP server */
$smtp->html_debug=0; /* Set to 1 to format the debug output as HTML */
$smtp->pop3_auth_host=""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */
$smtp->user=""; /* Set to the user name if the server requires authetication */
$smtp->realm=""; /* Set to the authetication realm, usually the authentication user e-mail domain */
$smtp->password=""; /* Set to the authetication password */
if(!function_exists("GetMXRR"))
{
$_NAMESERVERS=array();
include("GLOBAL/getmxrr.php");
}
$headers .= "Subject: $subject\r\n";
$smtp->SendMessage($from, array( $to ), $headers, $message);
/* if($smtp->SendMessage($from, array( $to ), $headers, $message))
{
echo "Message sent to $to OK.\n";
}
else
{
echo "Cound not send the message to $to.\nError: ".$smtp->error."\n";
} */
}
//send an email with html in it - all fields need to be complete
function email_html($contactname,$contactemail,$message,$subject,$id,$from)
{
include_once( "Company.php");
$o_company = new Company($id);
$myname = $o_company->getSitename();
$myemail = $o_company->getSiteemail();
$myreplyemail= $o_company->getSiteemail();
if($contactname == 'us')//email sent to us
{
$contactname = $o_company->getSitename();
}
if($contactemail == 'us')// email sent to us
{
$contactemail = $o_company->getSiteemail();
}
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$myname." <".$myemail.">\r\n";
$headers .= "To: ".$contactname." <".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname." <".$myreplyemail.">\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")."\r\n";
//$headers .= "X-Mailer:Mercury/32 v3.32";
C_Email::my_mail($contactemail, $subject, $message, $headers,$from);
}
//send an email with html in it - all fields need to be complete
function email_html2($contactname,$contactemail,$message,$subject,$myname,$myemail,$myreplyemail,$from)
{
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$myname." <".$myemail.">\r\n";
$headers .= "To: ".$contactname." <".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname." <".$myreplyemail.">\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")."\r\n";
//$headers .= "X-Mailer:Mercury/32 v3.32";
C_Email::my_mail($contactemail, $subject, $message, $headers,$from);
}
}
?>Thanks for any help!