Hi guys, I have a web page from where i send out email or fax to customers. The way the fax works is we shoot out an email to the add. 1231231234<fax@something.net> .I am using the faxback software for this and it only accepts html documents in the form of attachments and not in the body of the email. My problem is i cant get the send the attachment properly. Here is the code:
if ($action)
{
/ Wishes to send this output via email to the customer. /
//STEP ONE. Create tempfile
$email_fax_ad = $cust->email;
$server_name = "fax@banc.net";
$fax_string = htmlentities("<$server_name>");
//find out if sending a fax
if ($action == "send_fax")
{
$email_fax_ad = $cust->fax.$fax_string ;
}
$handle = fopen('../admin/tmp_email.html', 'w+');
$result = fwrite($handle, $output);
fclose($handle);
include('./class.html_mime_mail.inc');
define('CRLF', "\r\n", TRUE);
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
/***************************************
** Read the file into $attachment.
***************************************/
$image = $mail->get_file('../images/logo.gif');
$image2 = $mail->get_file('../admin/images/wholesale1.jpg');
$attachment = $mail->get_file('../admin/images/tmp_email.html');
/***************************************
** Since we're sending a plain text email,
** we only need to read in the text file.
***************************************/
$text = $mail->get_file('price_list_text_for_email.txt');
$html = $mail->get_file('tmp_email.html');
/***************************************
** To set the text body of the email, we
** are using the set_body() function. This
** is an alternative to the add_html() function
** which would obviously be inappropriate here.
***************************************/
$mail->add_html_image($image, '../images/logo.gif', 'image/gif');
$mail->add_html_image($image2, '../admin/images/wholesale1.jpg', 'image/jpeg');
//if sending fax the body of the email should not contain any image or html
if ($action == "send_fax")
{
$mail->add_attachment($attachment, 'pricelist', 'text/html');
}
else
{
$mail->add_html($html, $text);
}
/***************************************
** Builds the message.
***************************************/
$mail->build_message();
/***************************************
** Sends the message. $mail->build_message()
** is seperate to $mail->send so that the
** same email can be sent many times to
** differing recipients simply by putting
** $mail->send() in a loop.
***************************************/
//$mail->send($cust->personFirst.' '.$cust->personLast, 'rabbic@yahoo.com', 'Bancnet Customer Service', 'customerservice@banc.net', 'Bancnet Pricing Schedule');
if ($cust->email == "NULL")
echo "Error...no email present for this customer";
else
{
if ($action == "send_fax")
{
$mail->send($cust->personFirst.' '.$cust->personLast, $email_fax_ad, 'Bancnet Customer Service', 'customerservice@banc.net', 'Bancnet Price List');
//echo"<script> alert(\"FAX Successfully Sent to $cust->\"); </script>";
echo "fax sent to--> $email_fax_ad";
}
else
{
$mail->send($cust->personFirst.' '.$cust->personLast, $email_fax_ad, 'Bancnet Customer Service', 'customerservice@banc.net', 'Bancnet Price List');
echo"<script> alert(\"Mail Successfully Sent\"); </script>";
}
}
/***************************************
** Debug stuff. Entirely unnecessary.
***************************************/
}//END