Solved

PHP mail from prompt

Posted on 2014-04-15
5
210 Views
Last Modified: 2014-07-08
mail command works from PHP web script but not when I run it from prompt.

I run it by root and everything else in the script is working well, including updating database, etc.

Running CentOS with PHP 5.2.7

Here is php.ini mail dump:
# /usr/bin/php -i | grep -i mail | more
mail.force_extra_parameters => no value => no value
sendmail_from => no value => no value
sendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i
Path to sendmail => /usr/sbin/sendmail -t -i
MAIL => /var/spool/mail/root
_SERVER["MAIL"] => /var/spool/mail/root
_ENV["MAIL"] => /var/spool/mail/root
0
Comment
Question by:flowerbloom
  • 3
5 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40002881
No points for this please...

... with PHP 5.2.7
PHP 5.2 is not supported any more (not for several years) and is not supported even for security fixes.  My recommendation is to drop what you're doing and upgrade PHP now to PHP 5.4+ or PHP 5.5+ so you do not become the victim of an attack.  Then try this application again and come back to EE if you still are experiencing troubles.
0
 
LVL 19

Expert Comment

by:xterm
ID: 40004155
Please post your mail() command, and then tell us any output from it when you run it from the command line.  Also, look at the last few lines of the mail log at the time you send (tail -10 /var/log/maillog) and then afterwards, look in /var/spool/mqueue and /var/spool/clientmqueue to see if your mails are sitting there waiting to go out.

You might also turn up the debug level in your PHP script temporarily to get more output on what is or what is not working.

Your situation is unusual in that usually things will work fine when run as root from the CLI, but not so much when run via Apache's restricted environment.
0
 
LVL 1

Author Comment

by:flowerbloom
ID: 40041654
# mail -s subject person@domain.com
text
CTRL-D
cc: CTRL-D
#
0
 
LVL 1

Accepted Solution

by:
flowerbloom earned 0 total points
ID: 40174810
Emails were blocked by the firewall.  Firewall configuration has been modified, everything is well.
0
 
LVL 1

Author Closing Comment

by:flowerbloom
ID: 40182250
I research the issue and found a solution.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
The viewer will learn how to count occurrences of each item in an array.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now