
5th September 2006, 12:07
|
|
Moderator
|
|
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,010
Thanks: 254
Thanked 134 Times in 120 Posts
|
|
Weird problem when sending email from a PHP form.
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 "www-data@host.domainname.tld"
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: www-data@host.domainname.tld
I think if it would read www-data@domainname.tld 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: mail.info 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: 11.22.33.44
When sending from the PHP form:
Quote:
Sep 5 11:21:16 host postfix/pickup[11837]: DB072125000F: uid=33 from=<www-data>
Sep 5 11:21:16 host postfix/cleanup[14600]: DB072125000F: message-id=<20060905092116.DB072125000F@domainname.tld>
Sep 5 11:21:16 host postfix/qmgr[11838]: DB072125000F: from=<www-data@host.domainname.tld>, size=522, nrcpt=1 (queue active)
Sep 5 11:21:18 host postfix/smtp[14602]: DB072125000F: to=<email_address@gmail.com>, relay=gmail-smtp-in.l.google.com[72.14.205.27], delay=2, status=sent (250 2
Sep 5 11:21:18 host postfix/qmgr[11838]: DB072125000F: removed
|
When sending with SMTP (and all is ok!):
Quote:
Sep 5 11:24:21 host postfix/smtpd[15452]: connect from a11-22-33-44.adsl.cistron.nl[11.22.33.44]
Sep 5 11:24:21 host postfix/smtpd[15452]: 2E60B125000F: client=a11-22-33-44.adsl.cistron.nl[11.22.33.44], sasl_method=LOGIN, sasl_username=web4_me
Sep 5 11:24:21 host postfix/cleanup[15454]: 2E60B125000F: message-id=<004f01c6d0cd$46731ca0$0400000a@xeon2>
Sep 5 11:24:21 host postfix/qmgr[11838]: 2E60B125000F: from=<me@an_email_address>, size=685, nrcpt=1 (queue active)
Sep 5 11:24:21 host postfix/smtpd[15452]: disconnect from a11-22-33-44.adsl.cistron.nl[11.22.33.44]
Sep 5 11:24:22 host postfix/smtp[15455]: 2E60B125000F: to=<email_address@gmail.com>, relay=gmail-smtp-in.l.google.com[72.14.205.27], delay=1, status=sent (250 2
Sep 5 11:24:22 host postfix/qmgr[11838]: 2E60B125000F: removed
|
Last edited by edge; 5th September 2006 at 12:11.
|

5th September 2006, 12:31
|
|
Local Meanie
|
|
Join Date: Apr 2006
Location: Switzerland
Posts: 1,046
Thanks: 4
Thanked 33 Times in 31 Posts
|
|
Well, you could set a sender in the PHP form.
|

5th September 2006, 12:40
|
|
Moderator
|
|
Join Date: Jul 2006
Posts: 1,016
Thanks: 7
Thanked 56 Times in 51 Posts
|
|
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...
|

5th September 2006, 13:07
|
|
Moderator
|
|
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,010
Thanks: 254
Thanked 134 Times in 120 Posts
|
|
Quote:
|
Originally Posted by Ben
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...
|
This is part of the password recover code:
PHP Code:
if($_REQUEST['recover'])
{
STemplate::assign('receiver_name', $rs->fields['username']);
STemplate::assign('receiver_fname', $rs->fields['fname']);
STemplate::assign('receiver_lname', $rs->fields['lname']);
STemplate::assign('password', $rs->fields['pwd']);
$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:
PHP Code:
//MAIL FUNCTIION
function mailing($to,$name,$from,$subj,$body,$bcc="")
{
global $SERVER_NAME;
$subj=nl2br($subj);
$body=nl2br($body);
$recipient = $to;
if($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";
mail("$recipient","$subj","$body","$headers");
}
and a small part of the signup form
PHP Code:
{
$expired_time = date("Y-m-d H:i:s", strtotime("+".$rs->fields['trial_period']." day"));
$sql = "update subscriber set
pack_id=$_REQUEST[pack_id],
subscribe_time='".date("Y-m-d H:i:s")."',
expired_time='$expired_time'
where UID = $userid";
$conn->execute($sql);
SESSION_REGISTER("UID"); $_SESSION[UID]=$userid;
SESSION_REGISTER("EMAIL"); $_SESSION[EMAIL]="$_REQUEST[email]";
SESSION_REGISTER("USERNAME"); $_SESSION[USERNAME]="$_REQUEST[username]";
SESSION_REGISTER("EMAILVERIFIED"); $_SESSION[EMAILVERIFIED]="no";
####################### Email
$ran=time().rand(1,99999999);
$sql="update verify as v, signup as s set
v.vcode='$ran',
s.emailverified='no' WHERE v.UID=s.UID and v.UID='$userid'";
$conn->execute($sql);
STemplate::assign('vcode',$ran);
$to=$_SESSION[EMAIL];
$name=$config['site_name'];
$from=$config['admin_email'];
$rs = $conn->execute("select * from emailinfo where email_id='verify_email'");
$subj = $rs->fields['email_subject'];
$email_path = $rs->fields['email_path'];
$mailbody=STemplate::fetch($email_path);
mailing($to,$name,$from,$subj,$mailbody);
$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";
if($_REQUEST['add']!="")$add=base64_decode($add);
header("Location:$config[baseurl]/$page?$add");exit;
}
Not sure if this is all what is needed to fix the problem (it's not my code)
Last edited by edge; 5th September 2006 at 13:14.
|

5th September 2006, 14:15
|
|
Moderator
|
|
Join Date: Jul 2006
Posts: 1,016
Thanks: 7
Thanked 56 Times in 51 Posts
|
|
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.
PHP Code:
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: emai@domain.tld <emai@domain.tld>\r\n";
|

5th September 2006, 16:57
|
|
Moderator
|
|
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,010
Thanks: 254
Thanked 134 Times in 120 Posts
|
|
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..
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 12:21.
|
Recent comments
1 day 3 hours ago
1 day 12 hours ago
1 day 14 hours ago
1 day 16 hours ago
1 day 17 hours ago
1 day 19 hours ago
1 day 20 hours ago
1 day 21 hours ago
2 days 13 hours ago
2 days 14 hours ago