How to send e-mails with attachments from a PHP script?
The mail function of PHP supports also attachments. So, in creating the mail object we can add the attachment like this:
$to = ‘firstname.lastname@example.org’;
$subject = ‘Hello world with attachements’;
$attachment = chunk_split(base64_encode(file_get_contents(‘file_name.txt’)));
This is all, happy coding!