require 'class.phpmailer.php';
$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->IsSendmail(); // telling the class to use SendMail transport
$mail->SetFrom('[email protected]', 'Reporte ');
$address = "[email protected]";
$mail->AddAddress($address, "Reporte ");
$mail->Subject = "Reporte ";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML('Buenos dias estamos enviando el Reporte ');
//Reoordenar el archivo
$file = file('data.txt');
$fo = fopen('data.txt','w+');
$m = '';
foreach($file as $k => $f){
if($k < count($file)-1){
$m .= preg_replace("[\n|\r|\n\r]", '', $f) . "\r\n";
}else{
$m .= preg_replace("[\n|\r|\n\r]", '', $f);
}
}
fwrite($fo,$m);
fclose($fo);
$mail->AddAttachment("data.txt"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}