Jump to content

how to remove mailed-by?


mark103

Recommended Posts

Hi guys,

 

I need your help. I am using the code below to send email via using with php, however, I can't be able to remove the mailed-by hostname which is something like: server01.domain.com.

 

Here's the screenshot:

mailedbyld3.png

 

 

Here's the code:

if(isset($name)) {
   $name = $_GET['name'];
   $headers = "From: "-f .$name."@myemail.com"; 
   $to = "[email protected]";
   $subject = $type;
   $message = $comments . ' ' . $rate;
   $header = "From: Your Name <[email protected]>\l\n";
   $header .= "Reply-To: no answer <[email protected]>\l\n";
   $header .= "Return-Path: [email protected]\l\n";
   $header .= "Envelope-from: [email protected]\l\n";
   $header .= "MIME-Version: 1.0\l\n";
   $header .= "Content-Type: text/html\l\n";
   mail($to, "test", "hello,how r u today? I'm a Noobie", $header);
echo "Thank you for sent us your feedback";

 

When I use the code on above, the mailed-by hostname did not get removed. I want to remove it so I can send email to my clients for update email newsletters, registering form...etc

 

Anyone who know how to remove the mailed-by hostname would be much appreciate.

 

Thanks,

Mark

Link to comment
https://forums.phpfreaks.com/topic/224733-how-to-remove-mailed-by/
Share on other sites

Here it is:

 

<?php
session_start();
    define('DB_HOST', 'localhost');
    define('DB_USER', 'dbusername');
    define('DB_PASSWORD', 'dbpassword');
    define('DB_DATABASE', 'dbname');
       
$errmsg_arr = array();
    $errflag = false;

    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if(!$link) {

die('Failed to connect to server: ' . mysql_error());
    }

    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {

die("Unable to select database");
    }

   function clean($var){

return mysql_real_escape_string(strip_tags($var));
    }
    $name = clean($_GET['name']);
    $email = clean($_GET['email']);
    $comments = clean($_GET['comments']);

    if($name == '') {
  $errmsg_arr[] = 'name or member ID missing';
  $errflag = true;
    }
   else {
    }

    if($errflag) {
  $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
  echo implode('<br />',$errmsg_arr);
   }
   else {
$insert = array();
if(isset($_GET['name'])) {
    $insert[] = 'name = \'' . clean($_GET['name']) .'\'';
   // echo "tested";    
}
if(isset($_GET['email'])) {
    $insert[] = 'email = \'' . clean($_GET['email']) . '\'';
}
if(isset($_GET['type'])) {
    $insert[] = 'type = \'' . clean($_GET['type']) . '\'';
}
if(isset($_GET['comments'])) {
    $insert[] = 'comments = \'' . clean($_GET['comments']) . '\'';
}

if (count($insert)>0) {
   $names = implode(',',$insert);


if(isset($name)) {
   $name = $_GET['name'];
   $headers = "From: "-f .$name."@myemail.com"; 
   $to = "[email protected]";
   $subject = $type;
   $message = $comments . ;
   $header = "From: Your Name <[email protected]>\l\n";
   $header .= "Reply-To: no answer <[email protected]>\l\n";
   $header .= "Return-Path: [email protected]\l\n";
   $header .= "Envelope-from: [email protected]\l\n";
   $header .= "MIME-Version: 1.0\l\n";
   $header .= "Content-Type: text/html\l\n";
   $add = "-f my-website.com";
   mail($to, "test", "hello,how r u today?", $header);
echo "Thank you for sent us your feedback";
   }
   else {
if(isset($email)) {
   $headers = "From: $email";
   $to = "[email protected]";
   $subject = $type;
   $rate = $_GET['rate'];
   $message = ".$comments." ;
   $mailHeader = "MIME-Version: 1.0\r\n";
   $mailHeader .= "X-Sender: <{'google.com'}>\r\n";
   $mailHeader .= "Content-Type: text/plain; charset=UTF-8\r\n";
   $mailHeader .= "Content-Transfer-Encoding: quoted-printable\r\n"; 
   mail($to, $subject, $message, $headers, $mailHeader);
  }
echo "Thank you for sent us your feedback";
  }
}
}
?>

 

Hope you can help me to fix the problem i am getting.

 

Thanks in advance.

First, this is incorrect

<?php
$add = "-f my-website.com";
?>

the "-f" takes a regular email address as it's argument.

It should be

<?php
$add = "-f [email protected]";
?>

 

Second, you define $add, but never use it in your mail function. Try

<?php
mail($to, "test", "hello,how r u today?", $header,$add);
?>

 

Ken

Thanks for your quick response Ken, I have adjusted with the variable in two lines. However I am getting this:

 

Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE in /home/username/public_html/mysite.com/sendemail.php on line 79

 

The warning mail error are jumping on this line:

  mail($to, "test", "hello,how r u today?", $header,$add);

 

 

What I can do about it??  Should I get into the safe mode to modify or to create mail function??

Ken, I can see that the mailed-by have been disabled. However, please could you help me with this?

 

   $name = $_GET['name'];
   $header = "From: "-f .$name."@myemail.com"; 
   $to = "[email protected]";
   $subject = $type;
   $message = $comments . ' ' . $rate;
   $header .= "MIME-Version: 1.0\l\n";
   $add = "-f .$name. "@myemail.com";
   mail($to, "test", "hello,how r u today?", $header, $add);

 

 

I tried to send the email, but the php page have been blank. I am not sure that if my code is sound like a odd??

Thanks Coolkat, I have updated the code in my php. However I am getting the incorrect output email like this:

 

From: 1.0l <[email protected]:>

 

 

All I am trying to get rid of the "commime-version:" and extract the value from the $name method to included with my own email at the end like "[email protected]".

 

 

Here's the update code:

 

if(isset($name)) {
   $name = $_GET['name'];
   $header = "From: -f". $name  ."@myownemail.com"; 
   $to = "[email protected]";
   $subject = $type;
   $message = $comments . ' ' . $rate;
   $header .= "MIME-Version: 1.0\l\n";
   $add = "-f". $name ."@myownemail.com";
   mail($to, "test", "hello,how r u today?", $header, $add);
echo "Thank you for sent us your feedback";

The "From:" header should not contain the "-f", change

<?php
$header = "From: -f". $name  ."@myownemail.com"; 
?>

to (you also need the EOL character at the end of that header)

<?php
$header = "From: {$name}@myownemail.com\n"; 
?>

 

Ken

Thanks for the help ken, last thing I need before i will mark this thread as resolve. How I can check the methods between $name and $email that if I enter the value?

 

if(isset($name)) {
   $name = $_GET['name'];
   $headers = "From: "-f .$name."@myownemail.com";  
   $to = "[email protected]";
   $subject = $type;
   $message = $comments . ' ' . $rate;
   $header .= "MIME-Version: 1.0\l\n";
   $add = "-f". $name ."@myownemail.com";
   mail($to, $subject, $message, $header, $add);
echo "Thank you for sent us your feedback";
   }
   else {
   }
if(isset($email)) {
   $email = $_GET['email'];
   $headers = "From: ".$email.";  
   $to = "[email protected]";
   $subject = $type;
   $message = $comments . ' ' . $rate;
   $header .= "MIME-Version: 1.0\l\n";
   $add = "-f". $name ."@myemail.com";
   mail($to, $subject, $message, $header, $add);
  }
echo "Thank you for sent us your email";
  }

 

 

If I enter the value into 'name', it will work but if I enter the value into 'email', I get the blank page. Do you have any idea why I get it??

A few comments:

 

1.) earlier in your code you cleaned your input with a clean() function, but then right before actually using it, you reset the clean value to the unclean value with $name = $_GET['name'].. since $name already is the clean value of $_GET['name']

 

2.) you have $headers (notice the S) and then $header, it looks to me like you want to append them together but they have different names so that doesn't work. also if that is the case you need a new line after the from field.

 

3.) In the email section, you have $headers = "From: ".$email.";    so the last ." is not there and messing with your code.

 

As per your question are you asking how to check to make sure the information was entered into a form before sending the message? I think this would best be done in javascript on that page but you seemed to have it right there with the isset($email) and such.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.