0

I'm running Buster on my local server which, among other things, I use for developing web sites before copying them onto a public host. I've recently been getting into a little php coding because there seems to a lot of sample code out there for things I want to do. Usually they work right away when I try running them after having installed libapache2-mod-php.

Right now I'm trying to get a script working that is actually fairly small and seems straightforward. It displays a form that allows you to send an e-mail with an attachment. I actually have some similar scripts working locally that do pretty much the same thing, but I'm trying to get this one to work because the host I use for one site that needs this type of form has broken the script I had been using (I also didn't like it because it seemed overly complicated and under-featured).

This script use the Pear libraries to handle the heavy lifting, which seems like a reasonable design decision. I installed the php-pear package and also php-mail-mime. Unfortunately, the script failed to work. It was uploading the file but failing to send the e-mail.

I was able to find the line that was failing but it puzzles me. The line is

    $message = new Mail_mime();

which should be working (all it's doing is creating a new object). I ran the (frequently recommended) php-info page (<?php phpinfo();) and it shows a lot of information but nothing about mime. I'd expect that is something php handles though.

I got the script to send an e-mail by removing all the mime parts and just using the php mail() function. However that's not really useful. I need the mime bits to add the attachment.

Anyway, it looks like I need to do something more (besides restarting Apache2) to get php to use the php-mail-mime library but I'm not sure what. All the Debian information I've found just says "install the package php-<whatever> and it will work". Can anyone help me here?

Gary Dale
  • 79
  • 9
  • Where's the `include "Mail/mime.php";`? – mario Feb 17 '21 at 02:15
  • Right at the start of the script there are two includes: include_once('Mail.php'); include_once('Mail_Mime/mime.php'); – Gary Dale Feb 17 '21 at 04:46
  • And how did you verify those paths exist? – mario Feb 17 '21 at 05:33
  • I can't, which is the point I'm getting at. After installing the package containing the extra php/pear libraries, what else do I have to do to get this to work? I gather from your question that I may have to create site-specific copies/links to the libraries but I can't even locate where the libraries are installed. – Gary Dale Feb 17 '21 at 16:41
  • `/usr/share/php`, typically already in the `include_path`. So no, there's no copying or linking involved, unless you want to insist on the assumed path names. - Also, why the aversion to error_reporting? – mario Feb 17 '21 at 22:11
  • Thanks. When I went there, I noticed that there was no Mail_Mime folder, just a Mail folder that had mime.php in it. Removing the "_Mime" from the include allowed the script to proceed quite a bit further. It gets to where it is actually constructing the e-mail. Since there was no program "Mail.php" in the php directory, I installed php-mail and everything is now working. Again, thanks. – Gary Dale Feb 17 '21 at 22:49

0 Answers0