hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : PHP Mail (Sender: Nobody)
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

PHP Mail (Sender: Nobody)

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-09-2007, 07:19 PM
cmimrie cmimrie is offline
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.

__________________
Chris Imrie
Freelance Consultant
http://www.cimrie.com/


Reply With Quote


Sponsored Links
  #2  
Old 04-09-2007, 07:35 PM
horizon horizon is offline
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'], $msubjectstr_replace('[url]'urln($filex,$rn,$baseurl), $mbody)); 


Reply With Quote
  #3  
Old 04-09-2007, 07:40 PM
cmimrie cmimrie is offline
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.

__________________
Chris Imrie
Freelance Consultant
http://www.cimrie.com/


Reply With Quote
Sponsored Links
  #4  
Old 04-09-2007, 08:00 PM
horizon horizon is offline
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'], $msubjectpreg_replace('/^{url}/i'urln($filex,$rn,$baseurl), $mbody)); 


Reply With Quote
  #5  
Old 04-09-2007, 08:08 PM
cmimrie cmimrie is offline
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.
Attached Thumbnails
Click image for larger version

Name:	nobody.jpg
Views:	265
Size:	17.2 KB
ID:	11011  

__________________
Chris Imrie
Freelance Consultant
http://www.cimrie.com/


Reply With Quote
  #6  
Old 04-09-2007, 09:39 PM
horizon horizon is offline
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 . . .

Reply With Quote
  #7  
Old 04-10-2007, 04:42 AM
Engelmacher Engelmacher is offline
Disabled
 
Join Date: Jul 2002
Posts: 452
Include a reply-to header.

Reply With Quote
  #8  
Old 04-10-2007, 05:07 PM
Ks Jeppe Ks Jeppe is offline
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'], $msubjectstr_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
Reply With Quote
  #9  
Old 04-10-2007, 05:27 PM
cmimrie cmimrie is offline
WHT Addict
 
Join Date: Jun 2006
Location: United Kingdom
Posts: 148
Thanks Ks Jeppe

Worked a treat.

__________________
Chris Imrie
Freelance Consultant
http://www.cimrie.com/


Reply With Quote
  #10  
Old 04-10-2007, 05:33 PM
Ks Jeppe Ks Jeppe is offline
Aspiring Evangelist
 
Join Date: Mar 2006
Posts: 418
Quote:
Originally Posted by SixtyClear View Post
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? ||


Reply With Quote
  #11  
Old 04-10-2007, 06:42 PM
Engelmacher Engelmacher is offline
Disabled
 
Join Date: Jul 2002
Posts: 452
Quote:
Originally Posted by Ks Jeppe View Post
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."

Reply With Quote
  #12  
Old 04-11-2007, 08:18 AM
Ks Jeppe Ks Jeppe is offline
Aspiring Evangelist
 
Join Date: Mar 2006
Posts: 418
Quote:
Originally Posted by Engelmacher View Post
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? ||


Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Yahoo Integrates Email Client with Dropbox Cloud Storage Web Hosting News 2013-04-04 14:31:40
Web Hosting Control Panel cPanel and WHM Version 11.32 Adds Features, Fixes Web Hosting News 2012-04-08 11:51:35
cPanel Launches Version 11.32 of Control Panel and Web Host Manager Web Hosting News 2012-02-15 12:46:33
SpamExperts IPv6 Whitelist Foundation Wins IPv6 Task Force Award Web Hosting News 2011-11-18 22:21:53
Email Provider OpenXchange Partners with Openwave Web Hosting News 2011-10-12 17:23:08


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?