Page 1 of 1

Problem with sending web data to a email account...

Posted: Thu Mar 25, 2010 3:42 am
by phpking
I have a Linux(Redhat) server to host my website. It used to be worked fine when people submit their info. by pressing submit button; data will send to my email account.
One day this function does not work anymore. I was told somebody submitted the info., and I haven't received any email.
I checked it myself. I found that "Your info. has been sent successfully" is shown, but I never got the email.

By the way, how to check if the smpt in linux is working. Thank you.

Below code is part of

Code: Select all

contact. php
 
<?
ob_start();
include('Constant.php');
session_save_path ($s_Save_Path);
session_start();
?>
...
...
 
<? if ($filled == "contact") { 
        $subject = "Online Survey";
 
        $mailbody = "========== Survey ==========\n".
                    "Name: $name\n".
                    "Email: $email\n".
                    "Tel: $tel\n".
                    "Fax: $fax\n".
            "==========  Content  ===========\n".
                    "$content".
            "\n=========================================";
        
        $headers .= "From: $name <$email>\n";
        $headers .= "Reply-To: $email\n";
        $headers .= "X-Mailer: PHP\n"; // mailer
        $headers .= "Return-Path: <$email>\n";  // Return path for errors
        
        if (mail("$c_AdminEmail", "$subject", "$mailbody", "$headers")){
            $sysmsg = "Your info. has been sent successfully";
        } else {
            $sysmsg = "Server Error ";
        }
 
?>
Below code is part of Constant.php

...
...

Code: Select all

    $s_Save_Path = "/usr/local/apache/htdocs/skilltest/sessionfile";
    $DBserver = "localhost";
    $DBuser = "root";
    $DBpw = "";
    $DBname = "WCPSPE";
    $DB_Path = "DB/";
    $genGraph = "/usr/local/apache/htdocs/skilltest/";
    $reportFolder = "/usr/local/apache/htdocs/reportFolder";
    $displayReportFolder = "../reportFolder";
    $skilltestFolder = "../skilltest/";
    
    $c_AdminEmail = 'my@myemail.com';

Re: Problem with sending web data to a email account...

Posted: Fri Mar 26, 2010 4:52 pm
by zerkig
My guess is that the smtp server might very well be running fine. The problem here is the script's design. It is using a classic spammer technique of spoofing the sender's email address. If the message is routed through any gateway that checks headers and the users email address is not specifically set up to send from your Linux server's IP then it will be discarded.

I would suggest that you change the script to
1) write a copy to disk/database before sending
2) use something like phpmailer with a direct remote connection to your domains smtp server instead of sendmail

but if you're in a hurry try changing line 24,25

$headers .= "From: $name <$email>\n";
$headers .= "Reply-To: $email\n";


to hard code an email address that has your Linux server in its spf record.