PHPmailer send link to different email address

06-29-09, 01:14 AM
|
|
Newbie Coder
|
|
Join Date: May 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!!!
|

07-01-09, 09:38 PM
|
|
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();
|

07-05-09, 08:39 PM
|
 |
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 );
|

07-07-09, 06:43 PM
|
|
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.
|

07-08-09, 08:30 PM
|
|
Newbie Coder
|
|
Join Date: May 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

07-17-09, 04:54 AM
|
|
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.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| 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
|
|
|
|