Skip to main content

Email Function

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$paf_data.="Kaleem ID,PAF,Date,PAF Rec Count,PAF AMOUNT,PRC[Status],PRC REC Count,PRC AMOUNT, M2.CSV, M2 REC Count, M2 Amount, DIF[Status],DIF REC Count,DIF Amount,RFA,RFA REC Count,RFA Amount,DIF ACK / NAK (FILE NAME),DIF ACK/NAK REC Count,PAF AMOUNT LESS M2 Amount,M2 AMOUNT LESS DIF \r\n";

$filename = "Report-for-".date("Y-m-d-his",strtotime("$date2")).".CSV";
$filePath = "./tmp/$filename";

$fp = fopen($filePath,"w");
fwrite($fp, $paf_data);
fclose($fp);
$File_Name_Array[0]= $filePath;
$email_to="kaleemaq06@gmail.com"; /*i.e "PEOPLE","MAF","BANK" and return coma separated email list*/
$email_subject = "WPS Invoice Data for the Month of".date("F_y",strtotime($date1)); // The Subject of the email
$email_from = "kaleemaq06@gmail.com"; // Who the email is from
$body = "Dear Kaleem,\n\n". "Please find the attachment for WPS Invoice Data.\n \n Regards,\n Administration". "\n".$email_from;
SendEmail($email_to, $email_from,$File_Name_Array, $body, $email_subject);

function SendEmail($email_to, $email_from,$File_Name_Array, $body, $email_subject)
{
$email_from="wps@peopleperfectae.com";
$fileatt_type = "application/octet-stream"; // File Type
$file_array = $File_Name_Array;

$email_from='wps@peopleperfectae.com';

$headers = "From: ".$email_from;

// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";

// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";

if(is_array($File_Name_Array))
{
for($x=0;$x<count($file_array);$x++){
$file = fopen($file_array[$x],"rb");
$data = fread($file,filesize($file_array[$x]));
fclose($file);
$fileEXploded=explode('/',$file_array[$x]);
$total=count($fileEXploded);
$total--;
$fileName=$fileEXploded[$total];
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$fileName\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}
}


$message.=$body;


$ok = @mail($email_to, $email_subject, $message, $headers);

if($ok) {
$email_status="<font face=verdana size=2>The file was successfully sent!</font>";
} else {
$email_status=("Sorry but the email could not be sent. Please go back and try again!");
}

}
?>
</body>
</html>

Comments

Popular posts from this blog

PHPMailer

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php require_once "class.phpmailer.php"; $mail = new PHPMailer; $mail->From = "muhammad.kaleem@people.com.pk"; $mail->FromName = "Kaleem People"; $mail->addAddress("muhammad.kaleem@people.com.pk", "Kaleem Add Address Name"); //Provide file path and name of the attachments //$mail->addAttachment("file.txt", "File.txt"); $mail->addAttachment("file.txt");   $mail->addAttachment("../images/profile-pic.jpg"); $mail->addAttachment("../report/20090520-074141_sr-march09 ...

Memoery Managment Problem

http://www.doc.ic.ac.uk/~eedwards/compsys/index.html 1. Given five memory partitions of 100Kb, 500Kb, 200Kb, 300Kb, 600Kb (in order), how would the first-fit, best-fit, and worst-fit algorithms place    processes of 212 Kb, 417 Kb, 112 Kb, and 426 Kb (in order)? Which algorithm makes the most efficient use of memory?  First-fit:  212K is put in 500K partition  417K is put in 600K partition  112K is put in 288K partition (new partition 288K = 500K - 212K)  426K must wait  Best-fit:  212K is put in 300K partition  417K is put in 500K partition  112K is put in 200K partition  426K is put in 600K partition  Worst-fit:  212K is put in 600K partition  417K is put in 500K partition  112K is put in 388K partition  426K must wait  In this example, best-fit turns out to be the best. 2. Assuming a 1 KB page size, what are the page numbers and offsets for the following address refer...

PHP Interview Questions

1.   Which is the latest version of PHP.  The latest stable version of PHP is  5.6.7  released at March 20, 2015 . 2.   Define PHP. PHP is an open source  server side scripting  language used to develop dynamic websites . PHP  stands for Hypertext Preprocessor , also stood for   Personal Home Page .  Now the implementations of PHP is produced by The PHP group .It was created by  Rasmus lerdorf in 1995  . It is a free software released under the PHP license . 3.   Who is the father of PHP. Rasmus Lerdorf known as the father of PHP . Php was created by Rasmus Lerdorf In 1995 . 4.   What is the current version of Apache. The latest  stable version of  Apache  is   2.4.12 , released  on 29th  January  2015. 5.   What is difference between unset and unlink.. Unset is used to delete(destroy) a variable whereas unlink used to delete...