Solved

PHP mail from prompt

Posted on 2014-04-15
5
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

929 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

15 Experts available now in Live!

Get 1:1 Help Now