php - Variable Not Being Sent In Email -
i'm bit stumped on since i'm using same setup in 1 of scripts , works. i'm setting link in e-mail system users unsubscribe. unsubscribe script same 1 i've used on , on know works, when e-mails sent out e-mail not in link. link should appear in email http://example.com/unsubscribe.php?id=encoded-email
appearing http://example.com/unsubscribe.php?id=
. if through code of variables filled out , have values i'm stumped why it's not showing in e-mail.
the variable should working $encodedto
. ideas?
require($_server['document_root']."/settings/functions.php"); require($_server['document_root'].'/php/class.phpmailer.php'); require($_server['document_root'].'/php/class.pop3.php'); require($_server['document_root'].'/php/class.smtp.php'); if(isset($_post['submit'])) { $conn = getconnected("oversizeboard"); if(empty($_post['company'])) { echo "company name required."; exit(); } else { $company = mysqli_real_escape_string($conn, $_post['company']); } if(empty($_post['name'])) { echo "contact name required."; exit(); } else { $name = mysqli_real_escape_string($conn, $_post['name']); } if(empty($_post['phone'])) { echo "contact phone required."; exit(); } else { $phone = mysqli_real_escape_string($conn, $_post['phone']); } if(empty($_post['date'])) { echo "load date required."; exit(); } else { $date = mysqli_real_escape_string($conn, $_post['date']); } if(empty($_post['start'])) { echo "start location required."; exit(); } else { $start = mysqli_real_escape_string($conn, $_post['start']); } if(empty($_post['end'])) { echo "end location required."; exit(); } else { $end = mysqli_real_escape_string($conn, $_post['end']); } if(empty($_post['position'])) { echo "position required."; exit(); } else { $position = mysqli_real_escape_string($conn, $_post['position']); } if(empty($_post['rate'])) { echo "job rate required."; exit(); } else { $rate = mysqli_real_escape_string($conn, $_post['rate']); } if(empty($_post['cargo'])) { $cargo = "not specified"; } else { $cargo = mysqli_real_escape_string($conn, $_post['cargo']); } if(empty($_post['height'])) { $height = "not specified"; } else { $height = mysqli_real_escape_string($conn, $_post['height']); } if(empty($_post['width'])) { $width = "not specified"; } else { $width = mysqli_real_escape_string($conn, $_post['width']); } if(empty($_post['length'])) { $length = "not specified"; } else { $length = mysqli_real_escape_string($conn, $_post['length']); } if(empty($_post['weight'])) { $weight = "not specified"; } else { $weight = mysqli_real_escape_string($conn, $_post['weight']); } if(empty($_post['miles'])) { $miles = "not specified"; } else { $miles = mysqli_real_escape_string($conn, $_post['miles']); } $oversizequery = "insert postedloads (company, name, phone, date, start, end, position, rate, cargo, height, width, length, weight, miles) values ('$company', '$name', '$phone', '$date', '$start', '$end', '$position', '$rate', '$cargo', '$height', '$width', '$length', '$weight', '$miles')"; if (mysqli_query($conn, $oversizequery)) { echo "your load has been posted."; $emailquery = "select * subscriptions"; $emailresult = mysqli_query($conn, $emailquery); while ($subscriber = mysqli_fetch_array($emailresult)) { // begin phpmailer smtp authentication $mail = new phpmailer(); $mail->issmtp(); // set mailer use smtp $mail->host = "localhost"; // specify main , backup server // begin php mailer headers $mail->from = "loadalert@example.com"; $mail->fromname = "example"; $mail->addreplyto("loadalert@example.com", "example"); $subjectdate = date('m/d/y h:i:s a'); $mail->subject = "new load alert! received alert @ " . $subjectdate; $mail->ishtml(true); // set email format html $to = $subscriber['email']; $mail->addaddress($to); $encodedto = rtrim(strtr(base64_encode($to), '+/', '-_'), '='); date_default_timezone_set("america/chicago"); $mail->body = '<!doctype html>'; $mail->body .= '<html>'; $mail->body .= '<body style="padding: 0; padding-top: 20px; margin: 0; font-family: verdana; text-align: center; background-color: #000;">'; $mail->body .= '<div style="padding: 10px; background-color: #fff; width: 80%; margin: 10px auto; border-radius: 20px;">'; $mail->body .= '<h1 style="text-transform: uppercase;">hello '.$subscriber['first_name'].'!'; $mail->body .= '<h1 style="text-transform: uppercase;">you have received new load alert!</h1>'; $mail->body .= '<h2>company details</h2>'; $mail->body .= '<ul style="list-style: none; text-align: left; width: 80%; margin: 0 auto;">'; $mail->body .= ' <li>company: '. $company .'</li>'; $mail->body .= ' <li>company contact: '. $name .'</li>'; $mail->body .= ' <li>company phone: '. $phone .'</li>'; $mail->body .= '</ul>'; $mail->body .= '<h2>load details</h2>'; $mail->body .= '<ul style="list-style: none; text-align: left; width: 80%; margin: 0 auto;">'; $mail->body .= ' <li>load date: '. $date .'</li>'; $mail->body .= ' <li>pickup location: '. $start .'</li>'; $mail->body .= ' <li>drop off location: '. $end .'</li>'; $mail->body .= ' <li>load rate: '. $rate .'</li>'; $mail->body .= ' <li> pilot car position: '. $position .'</li>'; $mail->body .= '</ul>'; $mail->body .= '<h2>additional load details</h2>'; $mail->body .= '<ul style="list-style: none; text-align: left; width: 80%; margin: 0 auto;">'; $mail->body .= ' <li>cargo: '. $cargo .'</li>'; $mail->body .= ' <li>height: '. $height .'</li>'; $mail->body .= ' <li>width: '. $width .'</li>'; $mail->body .= ' <li>length: '. $length .'</li>'; $mail->body .= ' <li>weight: '. $weight .'</li>'; $mail->body .= ' <li>approximate miles: '. $miles .'</li>'; $mail->body .= '</div>'; $mail->body .= '<div style="background-color: #000; color: #fff; padding: 10px;">'; $mail->body .= ' <p>you have received e-mail because subscribed load board. <a href="http://example.com/unsubscribe.php?id="'.$encodedto.' style="color: #ff0000; text-decoration: none; font-style: italic;">click here</a> unsubscribe.</p>'; $mail->body .= ' <p>to ensure receive these e-mails faster, please add address book.</p>'; $mail->body .= ' <p>please note: there no way guarantee how fast receive these e-mails. delivery of e-mail varies e-mail service provider. please keep in mind load board free, , our best bring service fast possible. thank you.</p>'; $mail->body .= '</div>'; $mail->body .= '</body>'; $mail->body .= '</html>'; } } else { echo "there error. please try again."; } mysqli_close($conn); if(!$mail->send()) { echo "message not sent. <p>"; echo "mailer error: " . $mail->errorinfo; } } else { echo "you not authorized view page!"; }
Comments
Post a Comment