Link to home
Start Free TrialLog in
Avatar of lawrence_dev
lawrence_dev

asked on

How do I add an email attachment to this mail script?

This email script sends text perfectly.  I need to add an attachment (XLS file) to this email script.  How do I accomplish?

I have tried several scripts such as PHPmailer on GitHub.com  and cannot get them to work.  

If you can suggest something easy that works...  

(Attachment is in the same directory as script)

$filename = 'backorders_2015-03-17.xls';

$to      = $receiver;
$subject = $filename;
$message = 'backorders from today';
$message = str_replace("\n.", "\n..", $message);
$headers = 'From: $myemail' . "\r\n" .
    'Reply-To: $myemail' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lawrence_dev
lawrence_dev

ASKER

Thanks for your help!  I went back to the folder and found a sample file and was able to get it to work...  Pretty easy!