PHP mail() how to set sender mail

前端 未结 1 1100
攒了一身酷
攒了一身酷 2021-02-05 18:17

This is my code:

$to = \'to@mail.com\';

$subject = \'test\';

$body = \'test\';

$header  = \'MIME-Version: 1.0\' . \"\\r\\n\";
$header .= \'Content-type: text/         


        
相关标签:
1条回答
  • 2021-02-05 18:55

    Try setting the envelope sender, as well setting the sender in the headers of the message, like so:

    $to = "to@to.com";
    $from = "from@from.com";
    $subject = "subject";
    $message = "this is the message body";
    
    $headers = "From: $from"; 
    $ok = @mail($to, $subject, $message, $headers, "-f " . $from);   
    
    0 讨论(0)
提交回复
热议问题