php5 mail() function sendmail error

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 21:09:22

I don't know, but you might try sendmail_path = /usr/sbin/sendmail -t -i. It's set so on webhosting which I use. Otherwise, you might want to check if phpinfo() contains correct settings for sendmail.

I take the error to indicate that you are missing the information that -t would be looking for, 'To:' , 'CC:' , or 'BCC:'

Try adding some extra info to your mail command line and see if that works:

php -r "mail('sadmicrowave@gmail.com', 'test subject', 'test body message', 'To: Receiver <receiver@email.com>');"

Look at the following sections in your phpinfo() output to make sure you're editing the correct file:

  • Loaded Configuration File
  • Additional .ini files parsed

If the file you edited is not listed in one of those sections, the changes will have no effect.

I solved my issue by utilising the SwiftMailer module where I can specify a mailserver to relay through. I used my company mailserver as the server property and continued specifying the options as follows:

require_once('/var/www/global/swiftmailer/lib/swift_required.php');
$transport = Swift_SmtpTransport::newInstance( 'mailout.usa.mycompany.com', 25 );
$mailer = Swift_Mailer::newInstance( $transport );
$message = Swift_Message::newInstance( 'Suggestion Status Update' )
    ->setFrom( array( 'uslonsweb003@no-reply.com' => 'SuggestionBox' ) )
    ->setTo( array( $pEmail => $username ) )
    ->setBody( $body, 'text/html' )
    ;
$result = $mailer->send( $message );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!