Permission denied while using PHP Mail using Postfix - php

I have installed postfix and dovecot properly and did all configurations as per this guide: http://www.krizna.com/ubuntu/setup-mail-server-ubuntu-14-04/
But when I try sending mail via terminal like:
sudo php -r "mail('xyz#xyz.com', 'test', 'test');"
It gives me the error
sh: 1: /etc/postfix: Permission denied
I tried doing chmod -R 777 to the /etc/postfix directory and I still get the same error.
What should I do to get this working? I just want to send mail from my server to other mails like Gmail (i.e. xyz#xyz.com to abc#gmail.com)
I have even configured the mx records and a records in my dns manager.
If I see the Postfix log, I have this:
Feb 2 12:30:33 myhost postfix/pickup[16695]: ED7A120FD3: uid=33 from=<www-data>
Feb 2 12:30:33 myhost postfix/cleanup[4891]: ED7A120FD3: message-id=<20160202173033.ED7A120FD3#xyz.com>
Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: hash:/etc/postfix/virtual lookup error for "xyz#xyz.com"
Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: ED7A120FD3: virtual_alias_maps map lookup problem for xyz#xyz.com -- message not accepted, try again later
I am using PHP 7 running Apache 2 on Ubuntu 14.04
(Note: Postfix and dovecot seems to be working cause I did telnet as given in the tutorial and got the correct response.)

You forgot to run sudo postmap /etc/postfix/virtual.

Got my problem solved. The permission error occured only when accessing Postfix from terminal. It works when accessed from PHP script.
Moreover, I had to modify PHP.ini sendmail path which I set as /etc/postfix before.

Related

Roundcube Mailbox isn't a valid mbox file

When I login to my local Roundcube mail client from the web browser, it shows empty Inbox/Sent folders with an error message. I'm using php7.3, nginx, mysql as a local tech stack.
Server error: STATUS: Mailbox isn't a valid mbox file (0.000 + 0.000
secs).
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
After a long investigation, I found the solution.
I just removed the leading line break from the file
/var/spool/mail/{YOUR_USERNAME}
And it worked like a charm.

MAMP server configuration error + PHP & MySQL error

I'm attempting to use MAMP on a windows laptop, so I can run a JavaScript experiment for my Phd. Unfortunately I can't seem to get past startup.When I open Mamp and select 'Start Servers' the following message pops up:
MAMP could not start servers as configuration is not valid. Please check logs...
Despite this message the Apache Server and My SQL Server boxes turn green to suggest they are active.
After looking through a few logs I find the following errors, but I'm not sure how to address or fix them.
Apache_error.log
[Sat Mar 03 08:10:15 2018] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
Php_error.log
[02-Mar-2018 21:10:22 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\MAMP\bin\php\php7.1.7\ext\php_imagick.dll' - The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
in Unknown on line 0
Mampapp.log
textMessage:The description for Event ID '-1073741724' in Source 'MySQL' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message, or you may not have permission to access them. The following information is part of the event:'D:\MAMP\bin\mysql\bin\mysqld.exe: ready for connections.
Version: '5.6.34-log' socket: '' port: 3306 MySQL Community Server (GPL)
'
Source:MySQL
Category:(0)
EntryType:Information
EventID:100
Thanks, any help is appreciated.
MAMP is for mac specific. You would better take Xamp cross-platform (personal recommendation) or Wamp that is windows specific.

Permissions denied when starting apache through webmin/virtualmin

I am trying to start my Apache server through both webmin and putty, but I am getting the same error codes.
Apache was running perfectly fine before we did a restart of our VPS, now all the services started except for Apache.
We are running CentOS, the main error we are getting is posted below:
May 23 21:56:47 www.mydomain.com httpd[6234]: AH00526: Syntax error on line 373 of /etc/httpd/conf/httpd.conf:
May 23 21:56:47 www.mydomain.com httpd[6234]: Wrapper /home/mydomain/fcgi-bin/php5.fcgi cannot be accessed: (13)Permission denied
Line 373: FCGIWrapper /home/vps78446/fcgi-bin/php5.fcgi .php
Line 374: FCGIWrapper /home/vps78446/fcgi-bin/php5.fcgi .php5
I have tried editing the permissions, looking at the files called by php5.fcgi, and anything else I could find on the internet.
getent passwd return:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
systemd-bus-proxy:x:997:994:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:996:993:systemd Network Management:/:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
dovecot:x:97:97:Dovecot IMAP server:/usr/libexec/dovecot:/sbin/nologin
dovenull:x:995:992:Dovecot's unauthorized user:/usr/libexec/dovecot:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
mailman:x:41:41:GNU Mailing List Manager:/usr/lib/mailman:/sbin/nologin
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
named:x:25:25:Named:/var/named:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
clamupdate:x:993:991:Clamav database update user:/var/lib/clamav:/sbin/nologin
Kalgon:x:500:500::/home/Kalgon:/bin/sh
vitalitygaming:x:502:502:Main Site:/home/vitalitygaming:/bin/sh
vps78446:x:503:502:Main Site:/home/vps78446:/bin/sh
scgaminguser.vitalitygaming:x:506:502:SCGamingUser:/home/vitalitygaming/homes/scgaminguser:/bin/false
development.vitalitygaming:x:507:502:Development:/home/vitalitygaming/homes/development:/dev/null
dadenz.vitalitygaming:x:508:502:Dennis:/home/vitalitygaming/homes/dadenz:/dev/null
can you give us the permissions for those files,
open terminal enter cd /home/vps78446/fcgi-bin/ then ls -la
post results:
edit:
run the command below
sudo chown -R www-data:www-data /home/vps78446/fcgi-bin
try to run Apache after that

Laravel error - Unknown: Failed opening required '. ./public' (include_path='.;C:\php\pear\') in Unknown on line 0

I'm working on Laravel 5 and I'm using PHP function php -S localhost:8888 folder-name - t to show the web site.
Everything is working fine until I updated to Window 10. Now, I try to run the project in my browser, I get a blank page and this message in my cmd:
[Mon Aug 03 00:17:05 2015] PHP Fatal error: Unknown: Failed opening
required 'public' (include_path='.;C:\php\pear\') in Unknown on line 0
What is going wrong?
It sounds like a permissions issue. I don't have much experiencing working with Laravel on Windows, but I just fixed a similar issue on an Ubuntu box.
The source of trouble for me was that I installed composer as root, so I had to remove ./vendor, change the owner and group of ~/.composer to ubuntu:www-data (ubuntu is my user, www-data is the Nginx user), and rerun composer install. I also made sure the ./storage permissions were recursively set to 775, and change the owner of my entire Laravel project to ubuntu:www-data.
Some stuff will definitely be different if you're on Windows, but hope this helps!
It is a permission error actually. But if you try to run directly from your localhost server, it will work.
On windows 10 PHP Server will not be able to access PHP Pear extension that is why it is showing this error.
If you are running XAMPP. you have to go to your apache localhost with http://localhost/laravel-folder/public.

php + ubuntu upgrade

Just upgraded from Ubuntu 12.10 to Ubuntu 13.10
But left old php.ini and httpd.conf
And this is what I get now:
Fatal error: require_once(): Failed opening required 'serverConstants.php' (include_path='.:/usr/share/php:/www/allSites') in /www/myproject/src/lib/starter.php on line 12
-rwxrwxrwx 1 www-data root 202 Jan 23 2013 /www/allSites/serverConstants.php
How is this even possible?
/www is mounted from host machine (Ubuntu runs in a VM) if that matters, but I did't have this problem before the upgrade
Some servers (particularly on shared servers, but could be anywhere) forbid access to "world writable" files and directories, as a security measure. The first thing to try is changing the permissions on this file to 644 or even 444.

Categories