This is the mail function; that's called
function mailmessage_nonsmtp($to, $subject, $body, $format, $fromaddress, $bcc) {
//Headers are separated by $sep (It may be necessary to use \n on some servers, but this not actually correct)
$sep = "\r\n"; //separater for headers
//subject must not have newline character and make max length of 70 characters
//body - each line should be separated with a LF (\n). Lines should not be larger than 70 characters.
//replace any \r\n, \n or \r with a space in subject line and only use 70 characters
$subject = str_replace("\r\n", " ", $subject);
$subject = str_replace("\n", " ", $subject);
$subject = str_replace("\r", " ", $subject);
//$subject = substr ( $subject, 0, 70 );
//replace any \r\n with \n and use wordwrap() to split the lines which will use \n for new line
//$body = str_replace("\r\n", "\n", $body);
//$body = wordwrap($body, 70, "\n");
$body = WrapText($body, 70, "\n", false);
//construct the header
$headers = "";
if ( $format == "html" ) { //To send HTML mail, you can set the Content-type header.
$headers .= "MIME-Version: 1.0" . $sep;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $sep;
//Mod added to convert double quote marks to the html equivilant
$body = str_replace('"', '"', $body);
//Mod added to convert single quote marks to the html equivilant
$body = str_replace("'", "'", $body);
}
$headers .= "From:" . $fromaddress . $sep;
if ( $bcc != "" ) {
$headers .= "Bcc:" . $bcc . $sep;
}
// Check for safe mode
if( ini_get('safe_mode') ){ //safe mode on
mail($to, $subject, $body, $headers); //Send with header.
}else{ //safe mode off
//Mod to overcome problem with some ISP not liking a Return-Path of root or nobody
//If safe mode is on, the the fifth parameter is disabled so may have to use the above line instead.
$addparam = "-f".$fromaddress;
mail($to, $subject, $body, $headers, $addparam); //Send with header
}
}
function WrapText($message, $length, $LE, $qp_mode = false) {
$soft_break = ($qp_mode) ? sprintf(" =%s", $LE) : $LE;
$message = FixEOL($message, $LE);
if (substr($message, -1) == $LE)
$message = substr($message, 0, -1);
$line = explode($LE, $message);
$message = "";
for ($i=0 ;$i < count($line); $i++)
{
$line_part = explode(" ", $line[$i]);
$buf = "";
for ($e = 0; $e<count($line_part); $e++)
{
$word = $line_part[$e];
if ($qp_mode and (strlen($word) > $length))
{
$space_left = $length - strlen($buf) - 1;
if ($e != 0)
{
if ($space_left > 20)
{
$len = $space_left;
if (substr($word, $len - 1, 1) == "=")
$len--;
elseif (substr($word, $len - 2, 1) == "=")
$len -= 2;
$part = substr($word, 0, $len);
$word = substr($word, $len);
$buf .= " " . $part;
$message .= $buf . sprintf("=%s", $LE);
}
else
{
$message .= $buf . $soft_break;
}
$buf = "";
}
while (strlen($word) > 0)
{
$len = $length;
if (substr($word, $len - 1, 1) == "=")
$len--;
elseif (substr($word, $len - 2, 1) == "=")
$len -= 2;
$part = substr($word, 0, $len);
$word = substr($word, $len);
if (strlen($word) > 0)
$message .= $part . sprintf("=%s", $LE);
else
$buf = $part;
}
}
else
{
$buf_o = $buf;
$buf .= ($e == 0) ? $word : (" " . $word);
if (strlen($buf) > $length and $buf_o != "")
{
$message .= $buf_o . $soft_break;
$buf = $word;
}
}
}
$message .= $buf . $LE;
}
return $message;
}
//-----------------------------------------------------------------
/**
* Purpose : Changes every end of line from CR or LF to CRLF.
* $LE is line ending characer which is normally '\n'
* @return string
*/
function FixEOL($str, $LE) {
$str = str_replace("\r\n", "\n", $str);
$str = str_replace("\r", "\n", $str);
$str = str_replace("\n", $LE, $str);
return $str;
}
and this is the email that's sent out:
if($course=="Online Anaphylasis Course")
{
$login=$login1; //logins to take the course1
$password=$password1;
}
else
{
$login=$login2; //logins to take the course2
$password=$password2;
}
//=================Edit Email body======================================================
$body="Dear ".$fname." ".$lname.",<br> Thank you for purchasing our : " . $course . " we hope you enjoy it.<br>";
$body .="To access your course details use the following information :<br><br>";
$body .="If you go to the course web site : " .$courseweb. "<br>";
$body .="Login by : " .$login. "<br>";
$body .="The password is: " .$password. "<br><br>";
$body .= "This purchase allows you to complete the course once, course completions are monitored by our office and once you have pressed print for your certificate we are informed of your completion. Further course accesses will be charged for. If you have any problems in printing your certificate please contact our office and we will be able to supply you with one.
<p>Any problems just let us know using the contact details below:<br>Tel: 0845 423 8993 or email:
<a href='mailto:coordinator@ecgtraining.co.uk'>ecgtraining.co.uk</a></p>";
mailmessage_nonsmtp($payer_email, $email_subject, $body, "html", $support_email_address, $support_bcc);