Jump to content

Dynamic Logo Link (Hopefullyl Easy)


hoopplaya4

Recommended Posts

I've got a question, that I hope is easy to answer.  Perhaps I'm overlooking something.

 

I have a form where the admin can send an email to multiple users at one time, using PHPMailer.  Now, in the PHPMailer script, I would like to dynamically embed an image unique to each user based on their email address.  For example, if I'm sending an email to [email protected] and [email protected], they will both have the following <img> in their email:

 

jdoe would have: <img src='http://www.domain.com/logo.php?&[email protected] />
jcool would have: <img src='http://www.domain.com/logo.php?&[email protected] />

 

Now, the emails are sending no problem, but the "img" is not being created dynamically for each email.  It shows up as:

 

  <img src='http://www.domain.com/logo.php?&[email protected] /> 

 

in both emails!!

 

Here's the Script, I'm currently using:

 

<?php

$emails= $_POST['emails'];
foreach ($emails as $e) {

$body = $html;
$body .= "<br><br><br><img src='http://www.domain.com/logo.php?email=". $e ."' />";

#initiate PHPMailer class
$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP  
$mail->Host     = "smtp.host.com"; // SMTP server  

#set the from e-mail address
$mail->From = $address;
#set the from name
$mail->FromName = $fullname;
#set the e-mail type to HTML
$mail->IsHTML(true);

#the subject of the email
$mail->Subject = stripslashes($_POST["subjectpost"]);
#the HTML content of the email
$mail->Body = $body; 
#the plain text version
$mail->AltBody = $plain;

$mail->AddAddress('[email protected]);

$names = $_POST['emails'];
foreach ($names as $n) { 
$mail->AddCC($n);
} }  }

$mail->ClearAddresses(); 

?>

Link to comment
https://forums.phpfreaks.com/topic/137277-dynamic-logo-link-hopefullyl-easy/
Share on other sites

Does the logo.php actually work...have you tested that?

 

As far as I can tell it looks like it should work, I am not sure on the PHPMailer and IsHTML portion, but also check that your email client allows HTML and does not convert them to regular text. Also check that images are allowed.

Thanks for the reply, Premiso.

 

Yes, the image is working.  I know this because I have it post to a Database every time it's accessed.  They just both have the same "email" name.

 

It doesn't appear to be any HTML or Client issue.  It's just weird that it is not creating the name dynamically. 

 

Any other ideas?  (It's probably something I'm missing or overlooking).

A somewhat interesting update:

 

Instead of sending the email, I set up the PHP Script to "echo" the variables instead.  And, they are showing up as they should:

 

TEST
logo.php?subject=Test Email&[email protected]

TEST
[email protected]
logo.php?subject=Test Email&[email protected]

 

Then, in further testing to figure out what the issue is, I have removed the image altogether, and instead, just displayed it as text.  Thus, it would display in the email as:

 

logo.php?subject=Test Email&[email protected]

 

Funny enough, it shows up as: logo.php?subject=Test Email&[email protected]

in both emails.  This leads me to believe it has something to do with PHPMailer.  Either, I'm placing the $body in the wrong area, or something else.

 

Any ideas?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.