Solved

PHP mail from prompt

Posted on 2014-04-15
5
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 110

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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
The viewer will learn how to count occurrences of each item in an array.

752 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