mail function with 2 header parameters

ariamehr14038

New member
Hello experts,
I use this code to send email to myself, as you can see I use header parameter to specify "From: " header:

@mail("user@domain.com", $_POST['Subject'], $Message . $_POST['Update'], "From: user@domain.com");

It works, but the email I get contains this in the headers:

X-PHP-Script: www.domain.com/update.php for 93.37.38.39
X-PHP-Originating-Script: 2989:update.php
From: user@domain.com

To remove the above 2 X-PHP headers, someone told me to use: "X-PHP-Script: "
To replace the X-PHP headers with null.
However, no idea how to use both "From:" headers and "X-PHP" header together.
Anyone can help please? :)
 
Hello experts,
I use this code to send email to myself, as you can see I use header parameter to specify "From: " header:

@mail("user@domain.com", $_POST['Subject'], $Message . $_POST['Update'], "From: user@domain.com");

It works, but the email I get contains this in the headers:

X-PHP-Script: www.domain.com/update.php for 93.37.38.39
X-PHP-Originating-Script: 2989:update.php
From: user@domain.com

To remove the above 2 X-PHP headers, someone told me to use: "X-PHP-Script: "
To replace the X-PHP headers with null.
However, no idea how to use both "From:" headers and "X-PHP" header together.
Anyone can help please? :)
To remove the X-PHP headers from your email, you can use the ini_set() function to disable the addition of these headers before sending your email.
 
Hello and thanks indeed,
You mean something like?

ini_set('X-PHP-Script', '');
ini_set('X-PHP-Originating-Script', '');
Here's an example:
PHP:
<?php
// Set the sendmail_path to a command that does not include X-PHP headers
ini_set('sendmail_path', '/usr/sbin/sendmail -t -i');

// Prepare the email headers
$headers = "From: user@domain.com\r\n";
$headers .= "Reply-To: user@domain.com\r\n";

// Prepare the email subject and message
$subject = $_POST['Subject'];
$message = $Message . $_POST['Update'];

// Send the email
$mailSent = mail("user@domain.com", $subject, $message, $headers);

if ($mailSent) {
    echo "Email sent successfully.";
} else {
    echo "Failed to send email.";
}
?>
 
Back
Top