php (php-mime-mail) setup on Debian/Stable (Buster) system [duplicate] - php

This question already has answers here:
How to load a PEAR package
(2 answers)
How can I get useful error messages in PHP?
(41 answers)
Closed 2 years ago.
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?

Related

How to run PHP file in github page website? [duplicate]

This question already has an answer here:
Why my contact form (php) does not work with GitHub pages?
(1 answer)
Closed 12 months ago.
So i was adding a .php file to my github website with an email sender form, but when i try running it on my website it makes me download it instead of making it run directly in the browser. I was also trying to research something and i saw something about apache, but i don't know how to do it and how it works.
What i tried is to change the extension to .html but unfortunately, it sended me a 405 error "not allowed".
I'm sure the code is right and the only thing is that it dosn't make me run it.
What i want is that the php file, runs on the browser instead of making me download it.
Assuming that by GitHub Website you mean GitHub Pages...
You can't.
GitHub websites are mostly static - you, as a developer, push html or markdown and github provides/generates static content for viewers/browsers.
If you want to have a PHP-based backend, you need to use a different service. Alternatively, if your PHP code can generate static html, you can run it in a github action and push the html into github pages - but once done, it will stay as is until the next run.
Edit: also check the video on their site, which among other things, says:
There are no databases to set up or servers to configure

run PHP code inside HTML without using xampp and apache? [duplicate]

This question already has answers here:
How can I run a php without a web server?
(4 answers)
Closed 2 years ago.
i know there are many similar questions but tbh none of them really fit.
I have no problems running the php part of my Webpage and everything works fine. Now im asking if there is a way to run my webpage including the php part without using having to start apache and typing in localhost.
I just wanna open up my html document with a browser and display it, nothing else. However then, the php code isnt really executed but its necessary for me as it displays an essential table with data. And no I cant use javascript for a very specific reason. I have to use php for my project but its a bit inconvenient having to start apache everytime and i just want to open up the document with firefox for example.
Unfortunately, this will not be possible as PHP is a server side language. As such, you will have to have an application to serve the content. With HTML, you are able to open it directly and display as the client (Browser) is able to read it directly. Browsers do not read PHP - when the server compiles the PHP, it is only sending the DOM (HTML, etc.) to the browser.
Like other people said, PHP is a server side language so you need to run a server on your machine.
But maybe you could try using small local server like the Symfony Local Server
It should be faster to start than apache.

Application built on joomla displaying raw data on localhost

m having a strange problem never faced it before and tried every thing and i mean everything but no luck at all.
What happened was i downloaded the application source code built on joomla 1.7 via ftp from the live server and deployed it on my localhost and configured it correctly. Now what happened is it displaying some sort of raw data all over the browser window, attached is the screenshot.
Please guys its been 5 days since i stuck in this mess any help will be highly appreciated
Thanks in advance
Maybe you have installed an extension, which supports distribution of PHP code as binary code? There exist different extensions to PHP, which support this kind of functionality. Probably the most widespread is Zend Guard. To execute a script which was encrypted by this software your PHP needs to load the free loader extension provided by Zend. If your server has loaded this extension and your localhost does not, the output might be something like you encounter.
Your first step should be to compare the output of phpinfo of both servers. If Zend Guard (or a similar extension) is loaded on your production server and not on your localhost, this might be the problem. Next step should involve taking a look at the PHP files and search for one which contains lots of unreadable characters. If this seems unreasonable to you, you might as well just install Zend Loader and see if it works then, which might be less work.

Trouble running my PHP files [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Question about php and dreamweaver?
I am having alot of trouble running my php file. I downloaded XAMPP and have both Apache and MySQL running. Do I need to save the file in a certain place, and what does Dreamweaver mean when it says:
To preview pages containing server-side code, you need a testing server. Would you like to specify one now?
I have good enough knowledge in HTML and CSS, and have gotten websites running, but I can't seem to get PHP to work. When I just run the code from google chrome plainly it looks like this:
"Hello World"
"; phpinfo(); ?>
You can put your PHP-files into the xampp/htdocs folder, e.g. xampp/htdocs/hello.php and then open it in your browser at http://localhost/hello.php.
The URL must say localhost or whatever you set it to in order to render a PHP page. You also need to make sure PHP handlers are working and correctly parsing PHP files.

Open documents(pdf,doc,docx,txt) in browser page using php (without using google docs viewer) [duplicate]

This question already has answers here:
Is there a PDF parser for PHP? [closed]
(7 answers)
Closed 8 years ago.
My question is that i want to open documents(pdf,doc,docx,txt) in browser page using php (without using google docs viewer) can any one help me?
Some of these are doable. Some, not so much. Let's tackle the low-hanging fruit first.
Text files
You can just wrap the content in <pre> tags after running it through htmlspecialchars.
PDF
There is no native way for PHP to turn a PDF document into HTML and images. Your best bet is probably ImageMagick, a common image manipulation program. You can basically call convert file.pdf file.png and it will convert the PDF file into a PNG image that you can then serve to the user. ImageMagick is installed on many Linux servers. If it's not available on your host's machine, please ask them to install it, most quality hosts shouldn't have a problem with this.
DOC & DOCX
We're getting a bit more tricky. Again, there's no way to do this in pure PHP. The Docvert extension looks like a possible choice, though it requires OpenOffice be installed as well. I was actually going to recommend plain vanilla OpenOffice/LibreOffice as well, because it can do the job directly from the command line. It's very unlikely that a shared host will want to install this. You'll probably need your own dedicated or virtual private server.
In the end, while these options can be made to work, the output quality is not guaranteeable. Overall, this is kind of a bad idea that you should not seriously consider implementing.
I am sure libraries and such exist that can do this. Google could probably help you there more than I can.
For txt files I would suggest breaking lines after a certain number of characters and putting them inside pre tags.
I know people will not be happy about this response, but if you are on a Linux environment and have pdf2html installed you could use shell_exec and call pdf2html.
Note: If you use shell_exec be wary of what you pass to it since it will be executed on the server outside of PHP.
I thought I'd just add that pdfs generally view well in a simple embed tag.
Or use an object so you can have fall backs if it cannot be displayed on the client.

Categories