Weird problem when sending email from a PHP form.

Discussion in 'Installation/Configuration' started by edge, Sep 5, 2006.

  1. edge

    edge Active Member Moderator

    I've got this online registration for that will send a confirmation email back to the user.
    The problem is that when the email is send from the form it will show "[email protected]"
    Problem with this is that there is no SPF record for this, causing some registrations not to get to the user (hotmail does not accept mail when SPF is wrong)

    Now my HOSTNAME is host.domainname.tld, so I thought by adding host.domainname.tld to the existing SPF record for domainname.tld would fix it.
    Wrong.. The problem is still their.

    The problem is the from: [email protected]
    I think if it would read [email protected] that all is okay!

    I've had a look at PHP.ini, but see nothing where I can set this.

    Anyone here who might know how to fix this problem?

    This is the data from the: file
    (note that I have changed some things for privacy reasons)
    I have changed the domainname.tld, the email_address, an_email_address and the IP:

    When sending from the PHP form:
    When sending with SMTP (and all is ok!):
    Last edited: Sep 5, 2006
  2. sjau

    sjau Local Meanie Moderator

    Well, you could set a sender in the PHP form.
  3. Ben

    Ben ISPConfig Developer ISPConfig Developer

    Can you post the php code?

    What you additianlly can do is to set the -f parameter for sendmail in the php.ini to fix set the from address, wich is a real from address and no x-from address...
  4. edge

    edge Active Member Moderator

    This is part of the password recover code:

    $rs $conn->execute("select * from emailinfo where email_id='recover_password'");
    $subj $rs->fields['email_subject'];
    $email_path $rs->fields['email_path'];
    $body STemplate::fetch($email_path);
    mailing($_REQUEST['email'], $config['site_name'], $config['admin_email'], $subj$body);
    $msg "An email is sent to your email address. Plese check it now.";
    header("Location: recoverpass.php?msg=$msg");
    This is how the main mail function looks:
    function mailing($to,$name,$from,$subj,$body,$bcc=""
    $recipient $to;
    $bcc!=""$headers "Bcc: " $bcc."\n";
    $headers .= "From: " $from "\n";
    //$headers .= "X-Sender: <" . "$to" . ">\n";
        //$headers .= "Return-Path: <" . "$to" . ">\n";
        //$headers .= "Error-To: <" . "$to" . ">\n";
    $headers .= "Content-Type: text/html\n";
    and a small part of the signup form

    $expired_time date("Y-m-d H:i:s"strtotime("+".$rs->fields['trial_period']." day"));
    $sql "update subscriber set
    .date("Y-m-d H:i:s")."',
                                        where UID = 
    SESSION_REGISTER("UID");            $_SESSION[UID]=$userid;
    SESSION_REGISTER("EMAIL");            $_SESSION[EMAIL]="$_REQUEST[email]";
    ####################### Email                
    $sql="update verify as v, signup as s set
                                                s.emailverified='no' WHERE v.UID=s.UID and v.UID='

    $rs $conn->execute("select * from emailinfo where email_id='verify_email'");
    $subj $rs->fields['email_subject'];
    $email_path $rs->fields['email_path'];
    $msg "A verification email is sent to your address. Please check your email.";
    ##################### end Email SECTION 

    if($_REQUEST['next']!="")$page=$_REQUEST['next'].".php";else $page="invite_signup.php";
    Not sure if this is all what is needed to fix the problem (it's not my code)
    Last edited: Sep 5, 2006
  5. Ben

    Ben ISPConfig Developer ISPConfig Developer

    Well I splitted my lines of the header with \r\n instead of only \n but I'm note sure if there was a change or not...

    So my header var looks e.g. sth like this, if I don't use Pear's Mail class.
    $header "MIME-Version: 1.0\r\n";
    $header .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $header .= "From: [email protected] <[email protected]>\r\n";
  6. edge

    edge Active Member Moderator

    Thanks for the input, but I found the problem!

    In the mail function I had to replace: mail("$recipient","$subj","$body","$headers"); with mail("$recipient","$subj","$body","$headers","-f$from");

    (note the -f and $from)

    All is working fine now..

Share This Page