hoopplaya4 Posted December 17, 2008 Share Posted December 17, 2008 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 jdoe@gmail.com and jcool@gmail.com, they will both have the following <img> in their email: jdoe would have: <img src='http://www.domain.com/logo.php?&email=jdoe@gmail.com /> jcool would have: <img src='http://www.domain.com/logo.php?&email=jcool@gmail.com /> 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=jdoe@gmail.com /> 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('demo@demo.com); $names = $_POST['emails']; foreach ($names as $n) { $mail->AddCC($n); } } } $mail->ClearAddresses(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/137277-dynamic-logo-link-hopefullyl-easy/ Share on other sites More sharing options...
premiso Posted December 17, 2008 Share Posted December 17, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/137277-dynamic-logo-link-hopefullyl-easy/#findComment-717273 Share on other sites More sharing options...
hoopplaya4 Posted December 17, 2008 Author Share Posted December 17, 2008 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). Quote Link to comment https://forums.phpfreaks.com/topic/137277-dynamic-logo-link-hopefullyl-easy/#findComment-717302 Share on other sites More sharing options...
hoopplaya4 Posted December 17, 2008 Author Share Posted December 17, 2008 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=jdoe@gmail.com TEST jdoe@gmail.com logo.php?subject=Test Email&email=jcool@gmail.com 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=jdoe@gmail.com Funny enough, it shows up as: logo.php?subject=Test Email&email=jdoe@gmail.com 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? Quote Link to comment https://forums.phpfreaks.com/topic/137277-dynamic-logo-link-hopefullyl-easy/#findComment-717364 Share on other sites More sharing options...
hoopplaya4 Posted December 17, 2008 Author Share Posted December 17, 2008 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/137277-dynamic-logo-link-hopefullyl-easy/#findComment-717806 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.