• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

php mail, I can't solve this one, it must be simple

L

lawrencebrown

Guest
Hello,

First off, I must apologize, this topic has been covered loads and I have given it hours of my time now and I am still not getting anywhere. I am just trying to get the php mail function to send through my server. I have used this script time and time again with no problem - until on this server with plesk.

Can anyone advise on the changes that need to be made to ensure the emails get delivered?


<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

// *** Mail form as Text format ***
if (isset($_POST["FX_sendForm"]) && $_POST["FX_sendForm"] == "contact") {
$top = "\n";
$body = "\n";
$excludeArray = array("submit","submit_x","submit_y","null","FX_sendForm","MM_insert","MM_update");
$i = 0;
while ($i<sizeof($_POST)) {
if (!in_array(key($_POST),$excludeArray)) {
if (is_array(pos($_POST))) {
$postVar = implode(", ", pos($_POST));
} else {
$postVar = pos($_POST);
}
$body .= strtoupper(key($_POST)) . ": " . stripslashes($postVar) . "\n";
}
$i++;
Next($_POST);
}


$bottom = "\n";
$from = $_POST["Name"];
// set parameters
$recipient = "[email protected]";
$subject = "Message title";
$message = $top . $body . $bottom;
// set extra parameters
$headers = "From: " . $from . "\n";
$headers .= "Cc: \n";
$headers .= "Bcc: \n";
// send all
mail($recipient, $subject, $message, $headers);
$body = urlencode(str_replace("\n", "<br>", $body));
$redirect = "index.php";
if ($redirect) header("Location: " . $redirect);
}
?>


Thanks in advance. Lawrence
 
Back
Top