Author Topic: where to put the server name  (Read 5006 times)

0 Members and 1 Guest are viewing this topic.

Offline nameless

  • Full Member
  • ***
  • Posts: 147
    • View Profile
where to put the server name
« on: September 14, 2010, 05:30:24 PM »
hi evry one i do't know any thing about PHP
and i'm using this for emails (contact us) and it work very good until i change the host and it stop working
i send to know the reson he told me you must put the server name in your code and i do't know where to but it
so i hope some one help me

the code
Code: [Select]
<?
/*****************************************************************************/
$send_to = "SmartFormBuilder User <somehope2010@hotmail.com>";
$send_from = "www.xxxxx.com <somehope2010@hotmail.com>";

$subject = "اتصل بنا";
$autoresponder_from = $send_to;
$thanks_msg = "شكراً لك لمراسلتنا
سيتم الرد عليك باسرع وقت ممكن انشاء الله";
$autoresponder_subject = "Re: اتصل بنا";
$autoresponder_message = "شكراً لك لمراسلتنا

سيتم الرد عليك باسرع وقت ممكن انشاء الله";
/***************************************************************************/

do_formmail();

function do_formmail(){
    $form = get_form_data();
    send_mail($form);
    if ($autoresponder_enabled) auto_respond($form);
    done();
}

function get_form_data(){
    $vars = ($_SERVER['REQUEST_METHOD'] == 'GET') ? $_GET : $_POST;
    //strip spaces from all fields
    foreach ($vars as $k=>$v) $vars[$k] = trim($v);
    return $vars;
}

function _build_fields($vars){
    $skip_fields = array(
        'name_from',
        'email_from',
        'email_to',
        'name_to',
        'subject');

    foreach ($vars as $k=>$v)
        if (in_array($k, $skip_fields)) unset($vars[$k]);

    $max_length = 10; // max length of key field
    foreach ($vars as $k=>$v) {
        $klen = strlen($k);
        if (($klen > $max_length) && ($klen < 40))
            $max_length = $klen;
    }

    // make output text
    $out = "";
    foreach ($vars as $k=>$v){
        $k = str_replace('_', ' ', $k);
        $k = ucfirst($k);
        $len_diff = $max_length - strlen($k);
        if ($len_diff > 0)
            $fill = str_repeat('.', $len_diff);
        else
            $fill = '';
        $out .= $k."$fill...: $v\n";
    }
    return $out;
   
}

function send_mail($vars){
    global $send_to, $send_from;
    global $subject;
    global $REMOTE_ADDR;

    global $_FILES;
    $files = array(); //files (field names) to attach in mail
    if (count($_FILES)){
        $files = array_keys($_FILES);
    }

    // build mail
    $date_time = date('Y-m-d H:i:s');
    $mime_delimiter = md5(time());
    $fields = _build_fields($vars);
    $mail = <<<EOF
This is a MIME-encapsulated message

--$mime_delimiter
Content-type: text/plain
Content-Transfer-Encoding: 8bit

وصلك النموذج البريدي التالي:
$fields
--------------------
REMOTE IP : $REMOTE_ADDR
DATE/TIME : $date_time
EOF;

    if (count($files)){
        foreach ($files as $file){
            $file_name     = $_FILES[$file]['name'];
            $file_type     = $_FILES[$file]['type'];
            $file_tmp_name = $_FILES[$file]['tmp_name'];
            $file_cnt = "";
            $f=@fopen($file_tmp_name, "rb");
            if (!$f)
                continue;
            while($f && !feof($f))
                $file_cnt .= fread($f, 4096);
            fclose($f);
            if (!strlen($file_type)) $file_type="applicaton/octet-stream";
            if ($file_type == 'application/x-msdownload')
                $file_type = "applicaton/octet-stream";

            $mail .= "\n--$mime_delimiter\n";
            $mail .= "Content-type: $file_type\n";
            $mail .= "Content-Disposition: attachment; filename=\"$file_name\"\n";
            $mail .= "Content-Transfer-Encoding: base64\n\n";
            $mail .= chunk_split(base64_encode($file_cnt));
        }
    }
    $mail .= "\n--$mime_delimiter--";

    mail($send_to, $subject, $mail,"Mime-Version: 1.0\r\nFrom: $send_from\r\nContent-Type: multipart/mixed;\n boundary=\"$mime_delimiter\"\r\nContent-Disposition: inline");

}

function done(){
 echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=http://www.XXXXXX.com/index.php?template=thanks\">";   
}

function auto_respond($vars){
    global $autoresponder_from, $autoresponder_message, $autoresponder_subject;
    $_send_to = "$vars[name_from] <".$vars[email_from].">";
    $_send_from = $autoresponder_from;
    mail($_send_to, $subj, $msg, "From: $_send_from");
}
?>


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: where to put the server name
« Reply #1 on: September 14, 2010, 06:58:04 PM »
replace www.xxxxx.com with your domain name (there are 2 lines you need to edit)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline nameless

  • Full Member
  • ***
  • Posts: 147
    • View Profile
Re: where to put the server name
« Reply #2 on: September 14, 2010, 07:26:47 PM »
thanks v@no

there is the what thay say to me

In order to be able to send email through our hosting accounts that we offer you must use the following relay server in your code:

relay-hosting.secureserver.net

where i have to put this code


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: where to put the server name
« Reply #3 on: September 14, 2010, 07:58:41 PM »
I have no idea what they are talking about...are you referring to your host? That script uses PHP build-in mail() function, which relay on PHP configuration, if something needs to be done for that function to work, it has to be done in php.ini which your host's task, not yours as a customer...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)