Jump to content

mail() not working in browser but works fine from command line


DeX
 Share

Go to solution Solved by DeX,

Recommended Posts

I just set up my first mail server ever using Postfix and when I run 

echo testing | mail -s subjecttttt da***@*********.com

it sends fine and I receive the email at that address. The problem is when I create a php page on the server and write 

mail("da***@*****.com", "test", "test");

then run the page in my browser, it doesn't send the email.

From what I read online, it's because the root user on the command line has permissions to send mail while the www-data user in the browser does not. Is there a way I can specify which user Postfix uses? Any other suggestions? Thanks a lot.

Link to comment
Share on other sites

No, that will run echo as daemon but mail as bitnami. It would be

$ echo "subjectt" | sudo -u daemon mail -s "bodyy" d*****@*****.com

 

bitnami@ip-172-26-***.***:~$ echo "subjectt" | sudo -u daemon mail -s "bodyy" d*****@******.com
/home/bitnami/Maildir/sent: Permission denied
Failed to save message in "/home/bitnami/Maildir/sent" - message not sent
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.