I tried to attach my local file using PHP Mailer. I'm getting attachment only if the attachment file is in own server, but when I tried to attach the file from my c drive say [C:\Users\emp10144\Downloads], am getting attachment but with blank page. Did I need to modify my codings. Below is the codings I have used.
$mail->From = 'admin123@sampledemos123.online';
$mail->FromName = 'Admin';
$mail->AddAddress('targetmail@gmail.com', 'User'); // Add a recipient
//$mail->AddAddress('ellen@example.com'); // Name is optional
//$mail->AddAttachment('Daily_Milk_Report.csv','Daily_Milk_Report.csv');
This is working fine as the attcahment file is in own server
$filename = "C:\Users\emp10144\Downloads','Daily_Milk_Report.csv"; // Need to attcah this file from C drive/folder.
//$string = file_get_contents("C:\Users\emp10144\Downloads\sample.pdf");
$mail->AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/vnd.ms-excel');
$mail->IsHTML(true); // Set email format to HTML