Thread: Emailer

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Emailer


    hi
    i have a problem running a while loop in a emailer. i need to send the email a number of times. on the email is a voucher, each time one is created the barcode on each must change.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    well, that's interesting, but what are we supposed to do now?

    We're not psychic. We cannot magically find your problem based on a vague description of your script. If you want us to help, we need the actual code and a concrete error description (including any error message).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    can i email the code to you? i cant post it here, it gives an message bout [php] and stuff.....
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    [PHP
    include("a_connect.php");
    $uid = (!empty($_GET['uid']))?$_GET['uid']:"";
    $v = (!empty($_GET['v']))?$_GET['v']:"";



    //switch($v){

    //case "print":
    //header("location:../generate-ticket3.php?uid=".$uid);
    //break;
    //case "email":

    $i = 1;
    $counter = $_POST["counter"]; // counter is set in the form, the page before coming to this page
    while ($i <= $counter):

    $row = row("select * from city_ticketsbought where bought_uid='$uid'");
    $barcode = $row->bought_barcode;
    $voucher = $row->bought_voucher;
    $name = $row->bought_name;
    $date = $row->bought_date;
    $email = $row->bought_email;

    $todaydate = date('d M Y');
    $fromaddress = "email";
    $Subject ="Voucher Confirmation";
    $mailHeader = "From: " . $fromaddress;

    $theMessage="";
    $theMessage.="";

    $theMessage.="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><title>City Sightseeing</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
    $theMessage.="<style type=\"text/css\">";
    $theMessage.="<!--";
    $theMessage.="body, table, div, p {font-family: Arial, Helvetica, sans-serif;font-size:12px;}";
    $theMessage.="-->";
    $theMessage.="</style></head>";
    $theMessage.="<body><table width=\"576\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    $theMessage.="<tr><td colspan=\"2\" style='background:#de011b;'><img src='".$theURL."images/city-sightseeing_icon.jpg' width='110' height='130' /><img src='".$theURL."images/city-sightseeing.gif' width='229' height='130' /></td>";
    $theMessage.="</tr><tr>";
    $theMessage.="<td valign=\"top\"><br>";
    $theMessage.="<table width='576'><tr><td valign='top'><br><strong>Dear ".$name."</strong><br /></td><td align='right' width='200'>".$date ."<br>#".$barcode."<br>".$voucher."</td></tr>";
    $theMessage.="</table>";
    $theMessage.= "<br><a href='".$theURL."voucher.php?uid=".$uid."' target='_blank'>Print My Voucher</a><br /><br /><hr style=\"border-top:1px solid #000000;margin:10px 0px 10px 0px;\">";
    $theMessage.="<div style=\"font-size:9px;line-height:10px;\"></div></td>";
    $theMessage.="<td align=\"right\" valign=\"top\"></td>";
    $theMessage.="</tr><tr><td colspan=\"2\" valign=\"top\"><br>";


    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
    $mailHeader.= "\nMIME-Version: 1.0\n" .
    "Content-Type: text/html; charset=\"iso-8859-1\"\n" .
    "Content-Transfer-Encoding: 7bit\n\n";


    $toaddress = $email;
    $ok = mail($toaddress, $Subject, $theMessage, $mailHeader);

    $toaddress = "gaston@web2web.co.za";
    $ck = mail($toaddress, $Subject, $theMessage, $mailHeader);



    /**/

    echo("<div style='margin:20px auto 0px auto;color:#FFF;font-family:arial;font-size:14px;text-align:center;padding:40px;width:700px;background:#ff0000'>The voucher email has been sent to $email</div>");

    $i++;
    endwhile;
    ]
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    OK. And what's your question?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    I have to loop this a number of times (the user must enter how many times). Then the form must print that amount of times. but the barcode after every loop should be different.
  12. #7
  13. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Originally Posted by Gaston
    Then the form must print that amount of times.
    So? Just print $_POST["counter"].

    If you want to count the number of successful mails, use a separate counter that will only increment if $ok is true.



    Originally Posted by Gaston
    but the barcode after every loop should be different.
    Not sure what you're trying to do. As far as I can tell, the barcode comes from $row:
    PHP Code:
    $row row("select * from city_ticketsbought where bought_uid='$uid'");
    $barcode $row->bought_barcode
    But you always select the same (random) row in each loop run, so the bar code is always the same.

    If that's not what you want, then what do you want? You have multiple tickets (?) with each one having its own barcode, and you have a counter which is specified by the user. What is supposed to happen now?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    i cant get it to send the email when i run the while loop. when i take the while out, it just send one email. i need it to send a number of times the user wants it to. the loop is not working at this moment
  16. #9
  17. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Originally Posted by Gaston
    the loop is not working at this moment
    Um, and how were we supposed to know that?

    Check if $_POST["counter"] is correct with var_dump($_POST) and reduce the loop to the absolute minimum (just do something like echo $i).

    Also make sure you got your error_reporting turned on:
    PHP Code:
    error_reporting(-1

IMN logo majestic logo threadwatch logo seochat tools logo