I am trying to make a PHP code using the sendmail function. I can make it work using the PHP built-in mail() function, but those emails arrive with “Sender” info, which is different from the “From” address and some spam filters stop it as spam. Therefore, I want to try the sendmail thing. I just don't know how it works. I've tried this:
CODE
$to = ($_POST['youremail']);
$from = 'donotreply@domain.com';
$subject = 'Do Not Reply';
$body = "Testing...”;
function send_mail($to, $from, $subject, $body) {
$path_to_sendmail = "/usr/sbin/sendmail";
$fp = popen("$path_to_sendmail -t", "w");
$num = fputs($fp, "To: $to\n");
$num += fputs($fp, "From: $from\n");
$num += fputs($fp, "Subject: $subject\n\n");
$num += fputs($fp, "$body");
pclose($fp);
if ($num>0) { return 1; } else { return 0; } }
Unfortunately it doesn't send anything. Is there something missing, or does something need adjusting?
This code works, but it does the “Sender” thing, which I don't want.
CODE
$to = ($_POST['youremail']);
$from = 'donotreply@domain.com';
$subject = 'Do Not reply';
$body = "Testing...”;
mail($to, $subject, $body, "From: $from\n");