Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-29-2012, 02:21 AM   PM User | #1
mike92
New to the CF scene

 
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mike92 is an unknown quantity at this point
Check a user and display there email address???

Hi I am really stuck on a piece of code that checks the users username and then displays there email address ?
Any ideas?

Sorry I mean I want to display the email inside the code to forward an email to the correct username
for example user01@mydomain.com receives an email from user02@mydomain.com, I want the script to take the user01 and search the database for the forwarding email and then send it??

Last edited by mike92; 12-29-2012 at 04:33 PM.. Reason: Didn't explain enough
mike92 is offline   Reply With Quote
Old 12-29-2012, 08:22 AM   PM User | #2
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
No...there can be no ideas until you give us something tangible to think on. We may be awesome but we are not God.

Like give us a piece of code that you are stuck on. Or tell us to help you with the logic and give you ideas then.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Old 12-29-2012, 02:49 PM   PM User | #3
Clawed
New Coder

 
Join Date: Nov 2012
Location: United Kingdom
Posts: 34
Thanks: 3
Thanked 0 Times in 0 Posts
Clawed is an unknown quantity at this point
Quote:
Originally Posted by mike92 View Post
Hi I am really stuck on a piece of code that checks the users username and then displays there email address ?
Any ideas?
We can't do nothing without seeing code, but here's what i think you need:
PHP Code:

$username 
"Santa";
$query mysql_query("SELECT email FROM users WHERE username = '" $username "' LIMIT 1");
$row mysql_fetch_assoc($query);

echo 
$row['email']; 
Clawed is offline   Reply With Quote
Old 12-29-2012, 04:29 PM   PM User | #4
mike92
New to the CF scene

 
Join Date: Dec 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mike92 is an unknown quantity at this point
The Code

I have a pipe script which pipes the email's to PHP.
I want to forward the email to the correct username
for example user01@mydomain.com receives an email from user02@mydomain.com, I want the script to take the user01 and search the database for the forwarding email and then send it??

I am really new to this bellow is a very poor attempt which I know I have all wrong..........


PHP Code:
// from = there email
$from  "email@mydomain.com";
// to = there username 
$to ="$username";
// me= machine host name
$me    php_uname('n');
// host= smtp server 
$host  'localhost';
// msg= the original email message
$msg=$email;
// forward is the email address i want to forward to  
$forward=$data=mysql_query("SELECT * FROM users where $username='email'")
or die (
mysql_error ());
$info=mysql_fetch_array($data);
{
echo 
".$info['email'];
}
require_once '../../SMTP.php';
if(!($smtp = new Net_SMTP($host, 25, $me)))
  die("
sending mail failed to initializen");
if(PEAR::isError($smtp->connect(30)))
  die("
sending mail failed to connectn");
if(PEAR::isError($smtp->mailFrom($from)))
  die("
sending mail failed to set from address [$from]n");
if(PEAR::isError($smtp->rcptTo($to)))
  die("
sending mail failed to set RCPT TO [$forward]n");
if(PEAR::isError($smtp->data($msg)))
  die("
sending mail failed to set data and sendingn");
$smtp->disconnect(); 

Any help would be great
mike92 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:34 AM.


Advertisement
Log in to turn off these ads.