Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
764 views
in Technique[技术] by (71.8m points)

email - PHP mail: how to override or bypass mail.log setting

phpinfo() returns this particular setting which is problematic:

mail.log    /var/log/phpmail.log

The problem is I can't access the phpmail.log file to set the right CHMOD permissions on it, so my error_log is filling up with the following error each time a mail() fires off:

PHP Warning:  mail(/var/log/phpmail.log): failed to open stream: Permission denied

If it's at all possible I'd like to skip logging altogether. Otherwise, define a different log file that I can, you know, actually manipulate.

ps - this is not a duplicate of some other thread. I can't go changing the CHMOD values of above mentioned files, my question is about overriding a setting to skip email logging altogether.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I would first try to contact whoever is managing your server, he or she should fix this problem.

If that doesn't work, the mail.log setting is a PHP_INI_PERDIR setting, meaning that:

Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)

Obviously, you can't access the system's php.ini & httpd.conf, but if a .user.ini is provided to you, or you're allowed to change settings in .htaccess, then that would be a way to solve this.

See:
.user.ini files
Set php.ini Values Using .htaccess

Alternatively, you could consider using Swift Mailer or PHPMailer, which don't need the mail() function. In general, using mail() is discouraged, it's very basic and fairly difficult to use correctly & securely.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...