Current location: Hot Scripts Forums » Programming Languages » PHP » PHPmailer send link to different email address

PHPmailer send link to different email address

Reply
  #1 (permalink)  
Old 06-29-09, 01:14 AM
conmen80 conmen80 is offline
Newbie Coder
 
Join Date: May 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation PHPmailer send link to different email address

Hi all gurus here, I have a send mail problem need to solve urgently by using phpmailer.

I had built an notify message to users to inform them whenever their submission of form has been sent successfully, there is an url link for the user to allows them to click and direct open for review of what they had submitted.

Here comes a problem, I want the link to send to our admin too (which I use AddBCC() to add admin email, and send with user email concurrently) so that admin can check what the user has been submitted and do some task, but the link for admin is different from the user, how can phpmailer manage to define the different link in the message body to send either users or an admin?


Thanks!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-01-09, 09:38 PM
windows7 windows7 is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:
<?php
class Email
{
    public 
$fromName;
    public 
$fromAdd;    
    public 
$to;
    public 
$subject;
    public 
$content;    
    
    public 
$smtpEnable;
    public 
$host;
    public 
$port;
    public 
$username;
    public 
$password;
    
    function 
Email() // Constructor
    
{
        
/* 
        START: Get SMTP infomantion from App configuration 
        those config should be load from Prado application.xml
        Please rewrite carefully
        */
        
$this->smtpEnable    = (bool) $this->Application->Parameters['smtpEnable'];
        
$this->host            $this->Application->Parameters['smtpHost'];
        
$this->port            $this->Application->Parameters['smtpPort'];
        
$this->username        $this->Application->Parameters['smtpUsername'];
        
$this->password        $this->Application->Parameters['smtpPassword'];
        
//* END: Get SMTP infomantion from App configuration */

        
$this->fromName    $this->Application->Parameters['noReplyName'];
        
$this->fromAdd    $this->Application->Parameters['noReplyAddress'];
        
$this->to        NULL;
        
$this->subject    NULL;
        
$this->content    NULL;    
    }
    
    public function 
sendByPhp()
    {
        
$headers  "MIME-Version: 1.0" "\r\n";
        
$headers .= "Content-type: text/html; charset=utf-8" "\r\n";
        
$headers .= "From: ".$this->fromName." <".$this->fromAdd.">" "\r\n";
        if(!
mail($this->to$this->subject$this->content$headers)) return false;
        return 
true;
    }
    
    public function 
sendBySmtp()
    {
        require_once 
"Mail.php";

        
$headers = array(
                        
"MIME-Version"     => "1.0",
                        
"Content-type"     => "text/html; charset=utf-8",
                        
"From"            => $this->fromName." <".$this->fromAdd.">"
                        
"To"             => $this->to,                         
                        
"Subject"        => $this->subject
                    
);
    
        
$smtp Mail::factory(
            
"smtp",    array (
                
"host"         => $this->host,
                
"auth"         => true,
                
"port"         => $this->port,
                
"username"     => $this->username,
                
"password"     => $this->password
            
)
        );
        
        
$mail $smtp->send($this->to$headers$this->content);
        if (
PEAR::isError($mail)) return false;
        return 
true;
    }
    
    public function 
send()
    {
        if(
$this->smtpEnable
        {
            if(
$this->sendBySmtp()) return true;
        }
        else
        {
            if(
$this->sendByPhp()) return true;
        }
        return 
false;
    }
}
?>
Using:
PHP Code:
$e = new Email();
$e->subject='Subject';
$e->content='message';

$e->to="email1@yahoo.com, ";
$e->send();

$e->to="email2@yahoo.com, ";
$e->send(); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-05-09, 08:39 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
Just use the PHP mail function, put it in the code with the admin info plugged in.
Like this:

mail ( $admin_email , $subject, $message );
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-07-09, 06:43 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 414
Thanks: 4
Thanked 27 Times in 26 Posts
Just like ruteckycs says.

Use two different mails.

mail($user_email,$subject,$message);
mail($admin_email,$admin_subject,$admin_message);

This will allow you to change any links or subject lines, so that the admin see's what the admin needs to.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-08-09, 08:30 PM
conmen80 conmen80 is offline
Newbie Coder
 
Join Date: May 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
thanks guy!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-17-09, 04:54 AM
conmen80 conmen80 is offline
Newbie Coder
 
Join Date: May 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
how can i mod code below to what i want?

PHP Code:
$mail     = new PHPMailer();
$mail->SetLanguage("en""phpmailer/language/");
$mail->IsSMTP();
$mail->IsHTML(true);
$mail->Host         "localhost";
$mail->SMTPAuth     true;
$mail->Username     "username";
$mail->Password     "password";
$mail->From           "sale@abc.com";
$mail->FromName       "abc company";
$mail->Subject       $subject;
$mail->AddAddress("$email""$name"); // user email
$mail->AddBCC("admin@abc.com");
$mail->AddAttachment($merge_ref.".pdf");
$mail->Body         $send_msg
Please advise..thank!

Last edited by conmen80; 07-17-09 at 04:56 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get the email address from a email? Idealws PHP 1 12-04-07 05:23 PM
maintaining the same email address in a form cedric813 Perl 1 11-27-07 12:22 AM
ASP: Sending a HTML form to an email address cancer10 ASP 1 02-09-07 06:09 PM
Import yahoo, msn, Gmail address book for particular yahoo, msn, Gmail Email Id srini_r_r PHP 1 07-20-06 02:52 AM
send data to email jilshi Everything Java 0 04-02-04 08:50 PM


All times are GMT -5. The time now is 07:44 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.