
04-09-2007, 07:19 PM
|
|
WHT Addict
|
|
Join Date: Jun 2006
Location: United Kingdom
Posts: 148
|
|
PHP Mail (Sender: Nobody)
Hello.
So I have a script which is emailing users a URL.
Here are the two parts of the code;
config.inc.php
PHP Code:
//mail setup
$msubject = "Example Subject";
$mbody= "Uploaded: [url]";
$mheaders = "";
upload.php
PHP Code:
if ( $_POST[email] ) {
mail($_POST[email],$msubject,str_replace("[url]",urln($filex,$rn,$baseurl),$mbody));
}
Now I have set the following in the httpd.conf;
PHP Code:
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f example@example.com"
Now everything is partially fine and dandy, as before I implemented the http line, it would send you an email from nobody@yourserverhostname.com and since the above modification it emails from example@example.com. However, the sender still shows as Nobody does anybody know how to modify this setting to show Example or my choice of Sender, I have tried many times and have yet to find a working solution.
Any help is much appreciated.
|

04-09-2007, 07:35 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2006
Posts: 961
|
|
Replace:
PHP Code:
if ( $_POST[email] ) { mail($_POST[email],$msubject,str_replace("[url]",urln($filex,$rn,$baseurl),$mbody)); }
with:
PHP Code:
if (isset($_POST['email']) && preg_match("/^\w(\.?[\w-])+@\w(\.?[\w-])+\.[a-z]{2,4}(\.[a-z]{2})?$/i", $_POST['email'])) { mail($_POST['email'], $msubject, str_replace('[url]', urln($filex,$rn,$baseurl), $mbody)); }
|

04-09-2007, 07:40 PM
|
|
WHT Addict
|
|
Join Date: Jun 2006
Location: United Kingdom
Posts: 148
|
|
That has no relation to the Nobody issue however.
Although I have implemented your modification, thanks.
|

04-09-2007, 08:00 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2006
Posts: 961
|
|
Right. The $mbody tag. Without knowing from which user information you're using to capture your recipient's name, let's try to:
replace:
PHP Code:
$mbody= "Uploaded: [url]";
with:
PHP Code:
$mbody= "Uploaded: {url}";
Then,
PHP Code:
if ( $_POST[email] ) { mail($_POST[email],$msubject,str_replace("[url]",urln($filex,$rn,$baseurl),$mbody)); }
with:
PHP Code:
if (isset($_POST['email']) && preg_match("/^\w(\.?[\w-])+@\w(\.?[\w-])+\.[a-z]{2,4}(\.[a-z]{2})?$/i", $_POST['email'])) { mail($_POST['email'], $msubject, preg_replace('/^{url}/i', urln($filex,$rn,$baseurl), $mbody)); }
|

04-09-2007, 08:08 PM
|
|
WHT Addict
|
|
Join Date: Jun 2006
Location: United Kingdom
Posts: 148
|
|
I don't quite think you understand what issue I am facing.
**Attached Image**
This shows what I mean about the incoming emails showing 'Nobody' as the sender.
|

04-09-2007, 09:39 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2006
Posts: 961
|
|
I think you would need to instantiate a class file in order to use an object that could declare a firstname, lastname, email address ect . . .
|

04-10-2007, 04:42 AM
|
|
Disabled
|
|
Join Date: Jul 2002
Posts: 452
|
|
Include a reply-to header.
|

04-10-2007, 05:07 PM
|
|
Aspiring Evangelist
|
|
Join Date: Mar 2006
Posts: 418
|
|
Man you keep confusing and misleading people on these php threads horizon  rather sad to see...
sixtyclear: A small trip to the php manual for mail() might solve your question  You need to include the "From" header like so:
PHP Code:
<?php $mheaders = "From: Example <example@example.com> \r\n";
if (isset($_POST['email']) && preg_match("/^\w(\.?[\w-])+@\w(\.?[\w-])+\.[a-z]{2,4}(\.[a-z]{2})?$/i", $_POST['email'])) { mail($_POST['email'], $msubject, str_replace('[url]', urln($filex,$rn,$baseurl), $mbody), $mheaders); } ?>
__________________
|| Semi-professional PHP developer || Exams right now, don't I just feel lucky? ||
Last edited by Ks Jeppe; 04-10-2007 at 05:07 PM.
Reason: Closing php tag
|

04-10-2007, 05:27 PM
|
|
WHT Addict
|
|
Join Date: Jun 2006
Location: United Kingdom
Posts: 148
|
|
Thanks Ks Jeppe
Worked a treat.
|

04-10-2007, 05:33 PM
|
|
Aspiring Evangelist
|
|
Join Date: Mar 2006
Posts: 418
|
|
Quote:
Originally Posted by SixtyClear
Thanks Ks Jeppe
Worked a treat.
|
You're welcome  If you need any more php help, my pm inbox is always open 
__________________
|| Semi-professional PHP developer || Exams right now, don't I just feel lucky? ||
|

04-10-2007, 06:42 PM
|
|
Disabled
|
|
Join Date: Jul 2002
Posts: 452
|
|
Quote:
Originally Posted by Ks Jeppe
Man you keep confusing and misleading people on these php threads horizon  rather sad to see...
|
I wouldn't call it "misleading" so much as "posting random garbage that has nothing to do with anything."
|

04-11-2007, 08:18 AM
|
|
Aspiring Evangelist
|
|
Join Date: Mar 2006
Posts: 418
|
|
Quote:
Originally Posted by Engelmacher
I wouldn't call it "misleading" so much as "posting random garbage that has nothing to do with anything."
|
Ay, i stand corrected 
__________________
|| Semi-professional PHP developer || Exams right now, don't I just feel lucky? ||
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
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
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|