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

后端 未结 4 1268
醉酒成梦
醉酒成梦 2020-12-21 12:35

phpinfo() returns this particular setting which is problematic:

mail.log    /var/log/phpmail.log

The problem is I can\'t access the phpmail

4条回答
  •  醉话见心
    2020-12-21 13:08

    I'm a newbie in PHP so I don't know if my solution is really a way to solve this issue or if it works due to a coincidence!

    I have the same problem presented here: a call to the PHP function mail() produces a PHP warning. It's all explained in the first message. I also don't possess the permission to edit the mail.log or the directory in which to save it.

    Googling, I found a code that call the mail() preceded with a @. I tried to use the code @mail() and it worked!

    So this is the working code that I use:

    $mail_to = "MyAddress@email.com";
    $mail_from = $email; // This e-mail address is taken by an HTML form
    $mail_subject = "Test PHP function";
    $mail_body = "

    This is the body message for the test of a PHP function!

    "; // HTML headers $mail_in_html = "MIME-Version: 1.0 "; $mail_in_html .= "Content-type: text/html; charset=iso-8859-1 "; $mail_in_html .= "From: <$mail_from>"; // Submission process if(@mail($mail_to, $mail_subject, $mail_body, $mail_in_html)) { print "E-mail sent!"; } else { print "Error: e-mail not sent."; }

提交回复
热议问题