I'm trying to send emails with text which has had all <br> tags replaced with \n and then all remaining html tags are removed. My problem is that the "\n" tags show up in the email instead of an actual new line.
function br2nl($string) {
$string = str_replace('<br>', ' \n', $string);
return $string;
}
$body=br2nl("$body");
$body=strip_tags($body);
//build the text only email list
$email_list2=array();
$resulty=mysql_query("select * from email_addresses where ishtml='0' and cat_id='$email_list_id'");
while($rowy=mysql_fetch_array($resulty)){
$name=s_s($rowy[full_name]);
$email_to=s_s($rowy[email]);
$ishtml=s_s($rowy[ishtml]);
if(strlen($email_to)>5 && validate($email_to)=="true"){
$email_list2[]="$email_to";
}else echo "fail";
}
/***************************************
** Setup some parameters which will be
** passed to the smtp::connect() call.
***************************************/
$params['host'] = $stmp; // The smtp server host/ip
$params['port'] = 25; // The smtp server port
$params['helo'] = exec('zimm.net'); // What to use when sending the helo command. Typically, your domain/hostname
$params['auth'] = TRUE; // Whether to use basic authentication or not
$params['user'] = $from_email; // Username for authentication
$params['pass'] = $password; // Password for authentication
/***************************************
** These parameters get passed to the
** smtp->send() call.
***************************************/
$send_params['recipients'] = $email_list2; // The recipients (can be multiple)
$send_params['headers'] = array(
'From: '.$from_email,
'To: AB Emblem Subscribers', 'Subject: '.$headline,
'MIME-Version: 1.0',
'Content-Type: text/plain; Charset=us-ascii' // Headers
// Headers
);
$send_params['from'] = $from_email; // This is used as in the MAIL FROM: cmd
// It should end up as the Return-Path: header
$send_params['body'] = "$body"; // The body of the email
/***************************************
** The code that creates the object and
** sends the email.
***************************************/
if(is_object($smtp = smtp::connect($params)) AND $smtp->send($send_params)){
echo "<span class=\"standard\">Email sent successfully!</span>"."\r\n\r\n";
// Any recipients that failed (relaying denied for example) will be logged in the errors variable.
print_r("<br>");
}else{
echo "<span class=\"standard\">Error sending mail</span>"."\r\n\r\n";
// The reason for failure should be in the errors variable
echo $smtp->errors;
}