Jump to content

send email script


mark103

Recommended Posts

Hi guys,

 

I am writing the php script to send the email. I have noticed when I picked up on my email, I can see that it have been covered with mailed-by: myservername.com. I want to hide it, but I can't find a way to get it resolve.

 

 

Here's the code:

 

<?php
session_start();
    define('DB_HOST', 'localhost');
    define('DB_USER', 'myusername');
    define('DB_PASSWORD', 'mypass');
    define('DB_DATABASE', 'mydbname');
       
    $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']);
    $type = clean($_GET['type']);
    $comments = clean($_GET['comments']);

if($name == ''){
   $errmsg_arr[] = 'name are missing.';
   $errflag = true;
} elseif($email == ''){
   $errmsg_arr[] = 'email are missing.';
   $errflag = true;
}

    if($errflag) {
  $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
  echo implode('<br />',$errmsg_arr);
   }
   else {
$insert = array();
if(isset($_GET['name'])) {
    $insert[] = 'name = \'' . clean($_GET['name']) .'\'';
}
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($email)){
   $name = $_GET['name'];
   $email = $_GET['email'];
   $header = "From: $name <$email>". "\r\n";  
   $to = "myname@myemail.com";
   $subject = $type;
   $message = "$comments & $rate";
   $header .= "MIME-Version: 1.0\l\n";
   $add = "<$email>";
   mail($to, $subject, $message, $header, $add);
echo "Thank you for sent us your email";
  }
}
}
?>

 

 

 

I guess that something got to do with this:

 

if(isset($email)){
   $header = "From: $name <$email>". "\r\n";  
   $header .= "MIME-Version: 1.0\l\n";
   $add = "<$email>";
  }

 

 

I have disabled the safe-mode, so do you know how I can hide the mailed-by header using with the code on above??

 

Any advice would be much appreciate.

 

Thanks in advance.

Link to comment
Share on other sites

yeah i did, so thanks for your help. However, how I can send the email for the clients to receive the email within 48 hours?

 

once the email leaves your application, it's subject to the whims of the ether. typically, most email is delivered within seconds, but it can take longer depending upon content, routing, polling interval of the destination client, etc. if your emails aren't delivered within 48 hours, it's likely an issue with the receiving SMTP server and/or the account on that server.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.