On 2021-02-18 09:06, Gary Dale wrote:
On 2021-02-16 17:56, Gary Dale wrote:
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
seem 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. 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?
The issue turned out to be that script had an incorrect include. It
asked for Mail_Mime/mime.php when the actual include should have been
Mail/mime.php. I suspect that the php package names may have changed
since the author wrote the script and they never bothered to update it.
Further to above, when I went to move the script to my host, I
discovered that the cPanel php-pear installer used the package names
from the original script. Their Mail_Mime package was actually called
that while their Mail package doesn't include mime.php.
My host's cPanel php-pear packages appear to be relatively recent as
some of the documentation has dates from last year. Perhaps the
different package names is a Debian thing?