I have some code I like. It works perfectly, has for years, on any server I put it on. What I like about it is it is only a few lines of code, I can send the email to anybody, they always get it, and I don't have to bother with SMTP user/pass.
For my purposes, I don't need elaborate scripts. I have downloaded and installed all the mailers (PHPmailer) but compared to my code of ~10 lines that does for me the same thing 100,000 lines of code attempts to do but doesn't work because the zip files off the sites are missing files, files are located in the wrong folders, or certain functions 'disabled' for security reasons, where none of the examples work, which means I have to dig in, wade through all the code and fix the examples, etc...
I was hoping there was a simpler solution. The code I have looks like this:
<?
$to = "to@mail.com";
$from = "from@mail.com";
$email_subject = "Test";
$email_message .= "Hello, \n\n";
$headers = 'From: '.$from."\r\n". 'Reply-To: '.$to."\r\n" . 'X-Mailer: PHP/' . phpversion();
@mail($to, $email_subject, $email_message, $headers);
?>
That is six lines of code.
I understand that I could spend the next 18 hours searching Google for this answer, but I thought if it wouldn't be too much trouble to come here and ask this question:
Let's say I had the exact same 6 lines of code, but I also needed to attach a file that was located in the same folder as the PHP file to send the email.
$file = dirname(__FILE__).'doc.pdf';
Is there a fast, economical way to modify the original six lines of code that works to send the message, to add to the PDF file as an attachment?