Reading mails on server with IMAP? - php

I'm setting up an email 'proxy-like' where notification emails are sent to the user that he has subscribed to, but he can reply to the email notification#site.com which should contain his reply. On the server-side I want to be able to read his email and add his reply to the database - the email is stored in the notification user inbox which is great, now to be able to read it with PHP.
So, I've been looking around for solutions for this, many solutions were IMAP so I thought I'd give a try but I cannot seem to figure my connection my server to open the inbox. I've adjusted to different ports, but none of them are able to connect.
imap_open("{localhost/imap:143}", "notification", "password");
I get errors like this:
Warning: imap_open(): Couldn't open stream {localhost/imap:143} in /var/www/site.com/www/mail.php on line 8
bool(false)
Notice: Unknown: Connection failed to localhost,143: Connection refused (errflg=1) in Unknown on line 0
Notice: Unknown: Connection failed to localhost,143: Connection refused (errflg=1) in Unknown on line 0
Notice: Unknown: Connection failed to localhost,143: Connection refused (errflg=1) in Unknown on line 0
Notice: Unknown: Connection failed to localhost,143: Connection refused (errflg=2) in Unknown on line 0
I don't understand, obviously this is my first time trying this but what is it that I'm clearly doing wrong with the connection?
EDIT: I started courier-imap now I get this:
Notice: Unknown: [CLOSED] IMAP connection broken (server response) (errflg=1) in Unknown on line 0
Notice: Unknown: [ALERT] Fatal error: No such file or directory: No such file or directory in Unknown on line 0

You are asking for basic debugging here, so I try, maybe this machtes
Have you tried to specify a mailbox? And btw you should actually use the right syntax, it is host:port/protocol whereas imap is the default protocol and you can leave it out:
imap_open("{localhost:143}INBOX", "notification", "password");
^^^^^^^^^^^^^ ^^^^^
Please compare with the many examples and notes on imap_openDocs.
Also as this is debugging, try:
var_dump(imap_errors(), imap_alerts());
Happy debugging.

I had exactly the same problem on my Ubuntu 11.04 system, and I've solved by creating the "Maildir" folders in my home directory (as described here) with the following commands:
cd ~
maildirmake Maildir
maildirmake Maildir/.Drafts
maildirmake Maildir/.Sent
maildirmake Maildir/.Trash
maildirmake Maildir/.Templates
chmod -R 700 Maildir
First of all, you should check for errors in the log file "/var/log/syslog" (for example by executing the command sudo tail /var/log/syslog).
In my log I had noticed the following error: imapd: chdir Maildir: No such file or directory.
So I've checked the configuration file "/etc/courier/imapd" and I saw that the MAILDIRPATH option was set to "Maildir":
#
# MAILDIRPATH - directory name of the maildir directory.
#
MAILDIRPATH=Maildir
Then I've created the "Maildir" folders as described above, and the "imap_open()" function finally worked.

Related

php-fpm - enabling it causes Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

I am running into an error while attempting to enable php-fpm so that I can have multiple versions of php running on several different domains on one Apache Ubuntu 20 server.
I initially followed these directions: https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-ubuntu-18-04
But it didn't seem to use php-fpm as seen by phpinfo(); Instead, it was still running php (the regular one).
Then I found these instructions: https://techexpert.tips/apache/apache-php-fpm-installation-ubuntu-linux/
This seemed to work (in theory) by disabling regular php.
But now even phpinfo(); doesn't work, which is in a file called 'info.php'. It contains contains only:
<?php
phpinfo();
?>
I get:
"
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required '/home/traini61/public_html/guacamole.org/wordfence-waf.php' (include_path='.:/usr/share/php') in Unknown on line 0
"
I don't understand the error. I tried disabling the 'wordfence' plugin referenced in the error then tried again but it failed in exactly the same way. I've had to run the 2nd set of directions backwards to restore the website.
Also, is there a simpler commandline program that can provide a text-GUI to more easily administer which versions of PHP are assigned to a specific domain in an apache multi-domain configuration?

Warning: mysqli::__construct(): (HY000/2002): No such file or directory in [duplicate]

This question already has answers here:
Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in
(17 answers)
Closed 2 years ago.
I'm totally stuck having spent a couple of days trying to figure this out...
I have set up an Apache web server (version 2.4.34) on my Mac OS running Mojave (10.14.3) and have installed the current version of MySQL Community Server (8.0.15). Both running perfectly as I can determine (from command line). I have PHP 7.1.23 installed. When I create a .php file with the following code and put it in my Sites directory and then in Safari go to http://localhost/~dave/hello.php I get this error:
"Warning: mysqli::__construct(): (HY000/2002): No such file or
directory in /Users/dave/Sites/hello.php on line 7 Connection failed:
No such file or directory".
Code in hello.php:
<?php
$servername = "localhost";
$username = "dave";
$password = "*****";
//Create connection
$conn = new mysqli($servername, $username, $password);
//Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
I have tried everything I can think of, including those suggestions in the other two similar posts (this one: My database user exists, but I still get an (HY000/2002): No such file or directory and this one: PHP Warning: mysqli::__construct(): (HY000/2002): No such file or directory (Debian GNU/Linux 9)), and I cannot connect to MySQl with php. In particular, I checked with the php info page and the socket for mysqli is given as var/mysql/mysql.sock. In the relevant table in mysql the value for socket is given as /tmp/mysql.sock. I tried changing the php.ini.default file by adding each of these sockets (in place of the empty value) and neither worked (still generates the same error). I thought that the 2002 MySQL socket error might be the problem, so I made a symlink by doing this:
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
but all that did was generate a new error:
Warning: mysqli::__construct(): The server requested authentication
method unknown to the client [caching_sha2_password] in
/Users/dave/Sites/hello.php on line 7
Warning: mysqli::__construct(): (HY000/2054): The server requested
authentication method unknown to the client in
/Users/dave/Sites/hello.php on line 7 Connection failed: The server
requested authentication method unknown to the client
So I removed the symlink...and returned to the original error.
I also tried replacing "localhost" with the IP address 127.0.0.1 as well as "localhost:3306" as other question threads have suggested. Nothing worked here either.
Please help, I am new to this kind of use of the computer/web design and I'm out of obvious (googleable/understandable) options.
Use 127.0.0.1 instead of localhost.
I got some help from some local tech guys in my area and it turns out that fixing the socket error was the first step, like I tried to do above. I eventually did it this way, using the solution by noun:
Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in
The second error message was then generated (same one as in my question, here again):
mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in /Users/dave/Sites/hello.php on line 7
Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in /Users/dave/Sites/hello.php on line 7
This was fixed by the SQL-based solution (June 9 2018 answer) to this question:
php mysqli_connect: authentication method unknown to the client [caching_sha2_password]
This SQL statement was simply run in MySQL from the terminal. After restarting the Apache server I reloaded the .php file in Safari and this resulted in a successful mysqli connection to MySQL with PHP. I also tried a PDO connection and this also worked.

After typing php artisan serve, encounter error when trying to reach 127.0.0.1:8000

I'm using IIS as web server,
after I ran php artisan serve on the terminal,
I encountered error when trying to reach 127.0.0.1:8000.
Warning: Unknown: failed to open stream: No such file or
directory in Unknown on line 0
Fatal error: Unknown: Failed
opening required 'C:\inetpub\wwwroot\laravel/server.php'
(include_path='.;C:\php\pear') in Unknown on line 0
I have tried to look for other answers here, but none of them seems to work.
Any idea what went wrong. Thanks in advance.
This error is coming cause in your working repository server.php file is missing.
Oops forgot to update .I've downloaded the laravel 5.4,It turns out I forgot to include the .dev file, it works now

PHP Apache site error: failed opening required 'C:/xampp/htdocs/tutorial_php/Übung1/seite1.php'

I am absolute beginner trying to get my first PHP script working on the localhost server.
I wrote some lines of code for it and saved it in the C:/xampp/htdocs folder.
After that step I wanted to load my site in my browser. The problem is, now I get this error message:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:/xampp/htdocs/tutorial_php/Übung1/seite1.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0
I read something about it, tried to set another permission, but nothing worked so far. Could you please help me?
try the following on your cmd line:
php -S localhost:8888 -t public

apns not connecting in php

i am new to push notifications and tried following to fix this but it still gives same error.
added C:\PHP\ext to the Windows path
added libeay32.dll and ssleay32.dll to C:\WINDOWS\system32\inetsrv
rebooted the server
first error:-
Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (0)' in C:\wamp\www\ApnsPHP-master\ApnsPHP\Abstract.php on line 396
second error:-
ApnsPHP_Exception: Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (0) in C:\wamp\www\ApnsPHP-master\ApnsPHP\Abstract.php on line 396
i am using a .pem file which was used before somewhere else
and also i am trying to run my file on localhost, does it matter ?
if someone knows something that what should i do to fix this error, then please help me !
and thanx in advance
You should look if SSL is enabled in your configuration.
To display your configuration simply copy/paste the following in some php file and browse to it with a browser:
<?php
phpInfo();
?>

Categories