PHP - Send Email To Multiple User Using Phpmailer
i want to send email to multiple user.this is my code:
Similar TutorialsDear all, I am using PHPMailer to send notification emails after someone submits the form and as a result I'm receiving an email which has only one line: "A new user has been registered to your website". What I want is to receive an HTML email (in a table format) with all the data in it. Data Field Date January 3, 2010 Name: Aaaaa Surname: BBbbb... Email: test@email.com Gender: male .... .... Which code do I need to add in my thanks.php file in order to do this. After filling all the data in www.domain.com/apply.php, it automatically directs the user to thanks.php file Here is my code (thanks.php): <?php require_once("phpMailer/class.phpmailer.php"); require_once("phpMailer/class.smtp.php"); require_once("phpMailer/language/phpmailer.lang-en.php"); $to_name = "My Website"; $to = "email@mydomain.com"; $subject = "A new user has been registered to my website"; $message = "A new user has been registered to my website"; $message = wordwrap($message,70); $from_name = "My Website"; $from = "email@mydomain.com"; //PHP SMTP version $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "mail.website.org"; $mail->Port =25; $mail->SMTPAuth = false; $mail->Username = "username"; $mail->Password = "password"; $mail->FromName = $from_name; $mail->From = $from; $mail->AddAddress($to, $to_name); $mail->Subject = $subject; $mail->Body =<<<EMAILBODY A new user has been registered to my website. EMAILBODY; $result = $mail->Send(); echo $result ? 'Thanks for your registering...' : 'Error'; ?> I have an auctions website and I want to create a feature that is similar to ebay in which users will receive an email if one of the auctions they are watching will end in less than 3 hours. I will be using a cron job to call up this page every 15 minutes. When the cron job executes, I would like it to send 1 email per auction to every user that has that auction on their watchlist if the auction will be ending in 3 hours. I don't know whether it needs to be a separate email for each user or one mass email where their emails are hidden. The 4 tables in my database we are concerned about are "auctions, "users, "watchlists" and "products." I am trying to use the script phpMailer to execute the code because I heard it was the best one. Anways here is what I have so far. I am missing alot because I had no clue what to do. <?php require("class.phpmailer.php"); $holder = mysql_connect("localhost", "user", "password"); mysql_select_db("database", $holder); // NEED TO FIX THIS // Need to get ALL of the auction id's where the end time is less than 3 hours and the notification hasn't already been sent // $auctionid = mysql_query("SELECT id FROM auctions WHERE DATE_ADD(NOW(), INTERVAL 3 HOUR) <= end_time AND notification = 0", $holder); // get the auction title of EACH of the auctions selected above which is not stored in the auctions table but in the products table..will be used for body of email /// AGAIN, NEED THIS TO GET ME ALL OF THE NAMES OF AUCTIONS THAT ARE ENDING IN 3 HOURS// $auctiontitle = mysql_query("SELECT name FROM products LEFT JOIN auctions ON auctions.product_id=products.id WHERE auctions.id = $auctionid", $holder); // PROBABLY NEED TO FIX THIS // Need to get ALL of the email addresses who have ANY of the above auction ids on their watchlist // $email = mysql_query("SELECT email FROM users LEFT JOIN watchlists ON users.id=watchlists.user_id WHERE watchlists.auction_id = $auctionid", $holder); // Update the auctions table. Turn notification to 1 so the notification for that auction can't be sent again // AGAIN NEED THIS FOR ALL OF THE AUCTIONS ENDING IN 3 HOURS // $query1="UPDATE auctions SET notification = '1' WHERE id = '$auctionid'"; mysql_query($query1) or die(mysql_error()); $mail = new PHPMailer(); $mail->From = "no-reply@domain.com"; $mail->FromName = "Site Name"; // Getting and error message for the foreach but I saw a similar example and this is what I was told to do // NEED THIS TO ADD EACH OF THE EMAIL ADDRESSES INDIVIDUALLY // foreach ( $email as $recipients ) { $mail->AddAddress ($recipients); } $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = "Your Watched Auction is Ending Soon"; // Sample Body // WANT TO DISPLAY THE TITLE OF THE AUCTION (NAME OF PRODUCT) FOR THE AUCTION ID USING $auctiontile FROM ABOVE // $mail->Body = "Your auction titled $auctiontile is ending soon"; // Same as above // $mail->AltBody = Your auction titled $auctiontile is ending soon"; if(!$mail->Send()) { echo "Message could not be sent."; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; ?> Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after I am working on a phpmailer script that sends an order confirmation email to the customer AND the client at the same time. If I have the customer email and client email set both to the originating domain's email addresses (myname@myserver.com), then it sends fine. However, if I try to send to an outside mail server (eg. someone@gmail.com), I get the following errors: Code: [Select] SMTP -> FROM SERVER:220 myserver.com ESMTP Exim 4.63 Sat, 18 Sep 2010 15:08:21 -0700 SMTP -> FROM SERVER: 250 myserver.com Hello localhost [127.0.0.1] 250-SIZE 52428800 250-PIPELINING 250-AUTH LOGIN PLAIN 250-STARTTLS 250 HELP SMTP -> FROM SERVER:250 OK SMTP -> FROM SERVER:250 Accepted SMTP -> FROM SERVER: SMTP -> ERROR: RCPT not accepted from server: SMTP Error: The following recipients failed: someone@gmail.com Message could not be sent. Mailer Error: SMTP Error: The following recipients failed: someone@gmail.com SMTP server error: I'm not sure what's going on here. Any SMTP or phpmailer geniuses here that can shed some light on what needs to happen here for this to send to any address? Am trying to get an email address from the DB and send an alert but it's not working..
$search3 = mysql_query("SELECT email FROM users WHERE department = '$department' AND (position = '$position')") or die(mysql_error()); $acct1 = mysql_fetch_array($search3); $email = $acct1['email']; $to = $email; $subject = 'New Requisition Alert'; $message = 'You have a new message'; $headers = 'From: server@test.com' . "\r\n" . 'Reply-To: admin@test.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); Hi all, I am quite new to PHP and MySql. I know how to upload a file a and save the path in the DB, but now I need to send an automatic email to the user when a new invoice is added to his directory. Please help. Thanks Good morning, I'm writing a php script on a transaction creation/initiation. Only a registered user can initiate a transaction but if the second party to the transaction is not a registered user, the system will send a mail to the user informing him/her to accept and create an account. The whole idea is i have four conditional statement and each condition needs to send mail to the transaction initiator and the second party. so i am sending 8 mails but 2 at a time if and only if the condition is met. below is my code if ($mode==1){ //echo "Mode 1: ".$mode; $mode2 = 2; $sql = "SELECT * FROM reg WHERE email='$email'"; $query = mysqli_query($con,$sql); $rowreg = mysqli_fetch_row($query); $dbid = $rowreg[0]; $dbemail = $rowreg[1]; if (mysqli_num_rows($query)>0){ /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */ $mail = new PHPMailer(TRUE); /* Open the try/catch block. */ try { /* Set the mail sender. */ $mail->setFrom('no-reply@me.com', 'Mecom'); /* Add a recipient. */ $mail->addAddress("$email", "$full_name"); /* Set the subject. */ $mail->Subject = 'Transaction Created Successfully'; $mail->isHTML(TRUE); /* Set the mail message body. */ $mail->Body = '<div class="email-background" style="background: #eee;padding: 10px;"> <a href=""><center><img src="" style="padding-top:30px;padding-bottom:30px;max-width:100px;height:100px;margin: 0 auto;"></center><a> <div class="email-container" style="max-width: 500px;background: white;font-family: san-serif;margin: 0 auto;overflow: hidden;border-radius: 5px;text-align: center;"> <p style="margin: 20px;font-size: 12px;font-weight: 300;color: #666;line-height: 1.5;text-align:left"> Dear <b>' . $full_name . '</b>;<br/>We believe there is an agreement between you and <b>'. $fullname .' </b>for a transaction. Please see the details of the transaction below</p> <div class="table table-responsive" style="margin-left: 10px;margin-right: 10px;"> <table class="table table-striped table-bordered" style="max-width: 100%;background-color: transparent;border-collapse: collapse;border-spacing: 0;display: table;width: 100%;margin-bottom: 20px;border: 1px solid #ddd;"> <tbody style="display: table-row-group;vertical-align: middle;border-color: inherit;"> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="2" width="100%" style="text-align: center;background: #00bf6f;color: white;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;font-size:20px">Transaction Details <b>'.$transact_no.'</b></td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Title</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$db_cat_category.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Description</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$description.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Link</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$tran_link.'</td> </tr> '.$customerMail.' <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Item Worth/Price</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$price_format.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Charges bearer</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$charges.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Total Charges</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$chrg.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Who pay the charges?</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$chrgs.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Buyer Pays</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$buyer_t_pay.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Seller Receives</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$seller_t_receives.'</td> </tr> </tbody> </table> </div> </div> <div class="footer-junk" style="background: none;padding: 20px;font-size: 12px;text-align: center;"> Copyright © Mecom'. $year .' All Rights Reserved </div> </div>'; /* Finally send the mail. */ //$mail->send(); if (!$mail->send()){ /* PHPMailer error. */ echo $mail->ErrorInfo; }else{ $output ="<div class=\"alert alert-success\">Transaction has been created successfully</div>"; } catch (Exception $e) { /* PHPMailer exception. */ echo $e->errorMessage(); } catch (\Exception $e) { /* PHP exception (note the backslash to select the global namespace Exception class). */ echo $e->getMessage(); } // //End of First User //Second User // $fullname = $user["firstname"] . " " . $user["lastname"]; $full_name = $fname . " ". $lname; /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */ $mail = new PHPMailer(TRUE); /* Open the try/catch block. */ try { /* Set the mail sender. */ $mail->setFrom('no-reply@me.com', 'Mecom'); /* Add a recipient. */ $mail->addAddress("$dbemail", "$fullname"); /* Set the subject. */ $mail->Subject = 'Transaction Created Successfully'; $mail->isHTML(TRUE); /* Set the mail message body. */ $mail->Body = '<div class="email-background" style="background: #eee;padding: 10px;"> <a href=""><center><img src="" style="padding-top:30px;padding-bottom:30px;max-width:100px;height:100px;margin: 0 auto;"></center><a> <div class="email-container" style="max-width: 500px;background: white;font-family: san-serif;margin: 0 auto;overflow: hidden;border-radius: 5px;text-align: center;"> <p style="margin: 20px;font-size: 12px;font-weight: 300;color: #666;line-height: 1.5;text-align:left"> Dear ' . $fullname . ',<br/>You just initiated a transaction with title <b>'. $cat_category .'</b> and description <b> '. $description .' </b>to <b>'. $full_name .' </b>. Below is the details of the transaction</p> <div class="table table-responsive" style="margin-left: 10px;margin-right: 10px;"> <table class="table table-striped table-bordered" style="max-width: 100%;background-color: transparent;border-collapse: collapse;border-spacing: 0;display: table;width: 100%;margin-bottom: 20px;border: 1px solid #ddd;"> <tbody style="display: table-row-group;vertical-align: middle;border-color: inherit;"> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="2" width="100%" style="text-align: center;background: #00bf6f;color: white;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;font-size:20px">Transaction Details <b>'.$transact_no.'</b></td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Title</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$db_cat_category.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Description</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$description.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Link</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$tran_link.'</td> </tr> '.$customerMail.' <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Item Worth/Price</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$price_format.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Charges bearer</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$charges.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Total Charges</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$chrg.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Who pay the charges?</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$chrgs.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Buyer Pays</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$buyer_t_pay.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Seller Receives</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$seller_t_receives.'</td> </tr> </tbody> </table> </div> </div> <div class="footer-junk" style="background: none;padding: 20px;font-size: 12px;text-align: center;"> Copyright © Mecom'. $year .' All Rights Reserved </div> </div>'; /* Finally send the mail. */ //$mail->send(); if (!$mail->send()){ /* PHPMailer error. */ echo $mail->ErrorInfo; }else{ // $output ="<div class=\"alert alert-success\">Transaction has been created successfully</div>"; echo "<script> window.onload = function() { sweetAlert({ title: 'Congratulations', text: 'Your transaction has been created successfully', type: 'success', confirmButtonColor: '#B6EA36' }, function () { window.location.href = './'; }); }; </script>"; } } catch (Exception $e) { /* PHPMailer exception. */ echo $e->errorMessage(); } catch (\Exception $e) { /* PHP exception (note the backslash to select the global namespace Exception class). */ echo $e->getMessage(); } // //End of Second User }else{ //if the second user that is not the initiator is not a registered user //Add user info into the database table for the main site table //include ('includes/randStrGen.php'); $reg_no = randStrGen(4); $check_ID_query = mysqli_query($con, "SELECT regNo FROM reg WHERE regNo='$reg_no'"); $i = 0; //if username exists add number to username while(mysqli_num_rows($check_ID_query) != 0) { $i++; //Add 1 to i $reg_no = $reg_no + $i; $check_ID_query = mysqli_query($con, "SELECT regNo FROM reg WHERE regNo='$reg_no'"); } /* echo "First Name ". $fname . "<br>"; echo "Last Name ". $lname . "<br>"; echo "Address ". $address . "<br>"; echo "Phone Number ". $phonenumber . "<br>"; echo "Registration Number ". $reg_gen . "<br>"; exit();*/ $sql_reg = "INSERT INTO reg(email,password,firstname,lastname,marital_status,phone_number,IDmeans,passportID,lastlogin,regNo,address,bank_acct_number,bank_acct_name,bank_name,real_pass,activation,regDate) VALUES('$email','0','$fname','$lname','0','$phonenumber','0','0',now(),'$reg_no','$address','0','0','0','0','0',now())"; $query_reg = mysqli_query($con,$sql_reg); $regid = mysqli_insert_id($con); $sql_reg_verify = "INSERT INTO account_verify(token_email,refno) VALUES('$email','$reg_no')"; $query_reg_verify = mysqli_query($con,$sql_reg_verify); //$regid = mysqli_insert_id($link); $sql_description = "INSERT INTO description(item_description,transactID) VALUES('$description','$transact_no')"; $query_description = mysqli_query($con,$sql_description); $descid = mysqli_insert_id($con); //$r_tran= $_SESSION['transID'] .$descid ; $sql = "INSERT INTO trans_tbl(transact_no,transact_date,agreement_status,mode_transactID,transact_catID,regID,descID,amount,shipcost,status,transaction_period,inspection_length,charges,amt_pay,comp_charges,transaction_link,payment_status,shipment_status,confirm_shipment,address,refno) VALUES('$transact_no',now(),'1','$mode','$cat','$user[id]','$descid','$price','0','0','0','0','$charges','0','$chrg','0','0','0','0','$address','0'), ('$transact_no',now(),'1','$mode2','$cat','$regid','$descid','$price','0','0','0','0','$charges','0','$chrg','0','0','0','0','$address','0')"; $query = mysqli_query($con,$sql); /* Sending mail to new user to update his/her password */ $encode_email = base64_encode(base64_encode($email)); $encode_reg = base64_encode(base64_encode($reg_no)); //$encode_transactiinID = base64_encode(base64_encode($_SESSION['transID'])); //$encode_parnterID = base64_encode(base64_encode($_SESSION['id'])); //$encode_modeID = base64_encode(base64_encode($mode)); $link_url="<a href=\"https://www.safetranzact.com/verify-account?token=$encode_reg\" style=\"text-decoration: none;display: inline-block;background: #00bf6f;color: white;padding: 10px 20px;border-radius: 5px;\">Review and Sign up</a>"; $year = date('Y'); //send email to the receiver //First user for non register // $full_name = $fname . " " . $lname; $fullname = $user["firstname"] . " ". $user["lastname"]; /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */ $mail = new PHPMailer(TRUE); /* Open the try/catch block. */ try { /* Set the mail sender. */ $mail->setFrom('no-reply@me.com', 'Mecom'); /* Add a recipient. */ $mail->addAddress("$email", "$full_name"); /* Set the subject. */ $mail->Subject = 'Account/Transaction Verification'; $mail->isHTML(TRUE); /* Set the mail message body. */ $mail->Body = '<div class="email-background" style="background: #eee;padding: 10px;"> <a href=""><center><img src="" style="padding-top:30px;padding-bottom:30px;max-width:100px;height:100px;margin: 0 auto;"></center><a> <div class="email-container" style="max-width: 500px;background: white;font-family: san-serif;margin: 0 auto;overflow: hidden;border-radius: 5px;text-align: center;"> <p style="margin: 20px;font-size: 12px;font-weight: 300;color: #666;line-height: 1.5;text-align:left"> Dear ' . $full_name. ',<br/>We believe there is an agreement between you and <b>'. $fullname .' </b> for a transaction. And we noticed that you have not yet signed up; Please Sign up and see the details of the transaction below</p> <div class="table table-responsive" style="margin-left: 10px;margin-right: 10px;"> <table class="table table-striped table-bordered" style="max-width: 100%;background-color: transparent;border-collapse: collapse;border-spacing: 0;display: table;width: 100%;margin-bottom: 20px;border: 1px solid #ddd;"> <tbody style="display: table-row-group;vertical-align: middle;border-color: inherit;"> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="2" width="100%" style="text-align: center;background: #00bf6f;color: white;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;font-size:20px">Transaction Details <b>'.$transact_no.'</b></td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Title</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$db_cat_category.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Description</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$description.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Link</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$tran_link.'</td> </tr> '.$customerMail.' <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Item Worth/Price</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$price_format.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Charges bearer</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$charges.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Total Charges</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$chrg.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Who pay the charges?</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$chrgs.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Buyer Pays</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$buyer_t_pay.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Seller Receives</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$seller_t_receives.'</td> </tr> </tbody> <tfoot> <tr> <td colspan="2">'.$link_url.'</td> </tr> </tfoot> </table> </div> </div> <div class="footer-junk" style="background: none;padding: 20px;font-size: 12px;text-align: center;"> Copyright © Mecom'. $year .' All Rights Reserved </div> </div>'; /* Finally send the mail. */ //$mail->send(); if (!$mail->send()){ /* PHPMailer error. */ echo $mail->ErrorInfo; }else{ $output ="<div class=\"alert alert-success\">Transaction has been created successfully</div>"; } } catch (Exception $e) { /* PHPMailer exception. */ echo $e->errorMessage(); } catch (\Exception $e) { /* PHP exception (note the backslash to select the global namespace Exception class). */ echo $e->getMessage(); } // // //End of First user for non register //Second user for register // $full_name = $fname . " " . $lname; $fullname = $user["firstname"] . " ". $user["lastname"]; $year = date('Y'); /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */ $mail = new PHPMailer(TRUE); /* Open the try/catch block. */ try { /* Set the mail sender. */ $mail->setFrom('no-reply@me.com', 'Mecom'); /* Add a recipient. */ $mail->addAddress("$dbemail", "$fullname"); /* Set the subject. */ $mail->Subject = 'Transaction Created Successfully'; $mail->isHTML(TRUE); /* Set the mail message body. */ $mail->Body = '<div class="email-background" style="background: #eee;padding: 10px;"> <a href=""><center><img src="" style="padding-top:30px;padding-bottom:30px;max-width:100px;height:100px;margin: 0 auto;"></center><a> <div class="email-container" style="max-width: 500px;background: white;font-family: san-serif;margin: 0 auto;overflow: hidden;border-radius: 5px;text-align: center;"> <p style="margin: 20px;font-size: 12px;font-weight: 300;color: #666;line-height: 1.5;text-align:left"> Dear ' . $fullname . ',<br/>You just initiated a transaction with title <b>'. $cat_category .'</b> and description <b>'. $description .' </b> to <b>'. $full_name .' </b> Below is the details of the transaction</p> <div class="table table-responsive" style="margin-left: 10px;margin-right: 10px;"> <table class="table table-striped table-bordered" style="max-width: 100%;background-color: transparent;border-collapse: collapse;border-spacing: 0;display: table;width: 100%;margin-bottom: 20px;border: 1px solid #ddd;"> <tbody style="display: table-row-group;vertical-align: middle;border-color: inherit;"> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="2" width="100%" style="text-align: center;background: #00bf6f;color: white;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;font-size:20px">Transaction Details <b>'.$transact_no.'</b></td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Title</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$db_cat_category.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Description</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$description.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Link</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$tran_link.'</td> </tr> '.$customerMail.' <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Item Worth/Price</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$price_format.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Charges bearer</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$charges.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Total Charges</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$chrg.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Who pay the charges?</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$chrgs.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Buyer Pays</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$buyer_t_pay.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Seller Receives</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$seller_t_receives.'</td> </tr> </tbody> </table> </div> </div> <div class="footer-junk" style="background: none;padding: 20px;font-size: 12px;text-align: center;"> Copyright © Mecom'. $year .' All Rights Reserved </div> </div>'; /* Finally send the mail. */ //$mail->send(); if (!$mail->send()){ /* PHPMailer error. */ echo $mail->ErrorInfo; }else{ echo "<script> window.onload = function() { sweetAlert({ title: 'Congratulations', text: 'Your transaction has been created successfully', type: 'success', confirmButtonColor: '#B6EA36' }, function () { window.location.href = './'; }); }; </script>"; } } catch (Exception $e) { /* PHPMailer exception. */ echo $e->errorMessage(); } catch (\Exception $e) { /* PHP exception (note the backslash to select the global namespace Exception class). */ echo $e->getMessage(); } //$mail4->ClearAllRecipients(); // //End of Second user for register } }else{ ///////////////////////Second condition with //echo "Mode 2: ".$mode; $mode2 = 1; $sql = "SELECT * FROM reg WHERE email='$email' LIMIT 1"; $query = mysqli_query($con,$sql); $rowreg = mysqli_fetch_row($query); $dbid = $rowreg[0]; $dbemail = $rowreg[1]; if (mysqli_num_rows($query)>0){ //Add user info into the database table for the main site table $sql_description = "INSERT INTO description(item_description,transactID) VALUES('$description','$transact_no')"; $query_description = mysqli_query($con,$sql_description); $desc_id = mysqli_insert_id($con); //$r_tran= $_SESSION['transID'] .$descid ; $sql = "INSERT INTO trans_tbl(transact_no,transact_date,agreement_status,mode_transactID,transact_catID,regID,descID,amount,shipcost,status,transaction_period,inspection_length,charges,amt_pay,comp_charges,transaction_link,payment_status,shipment_status,confirm_shipment,address,refno) VALUES('$transact_no',now(),'1','$mode','$cat','$user[id]','$desc_id','$price','0','0','0','0','$charges','0','$chrg','$tran_link','0','0','0','$address','0'), ('$transact_no',now(),'1','$mode2','$cat','$dbid','$desc_id','$price','0','0','0','0','$charges','0','$chrg','$tran_link','0','0','0','$address','0')"; $query = mysqli_query($con,$sql); //First user to received email // $full_name = $fname . " ". $lname; $fullname = $user["firstname"] . " ". $user["lastname"]; $year = date('Y'); /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */ $mail = new PHPMailer(TRUE); /* Open the try/catch block. */ try { /* Set the mail sender. */ $mail->setFrom('no-reply@me.com', 'Mecom'); /* Add a recipient. */ $mail->addAddress("$email", "$full_name"); /* Set the subject. */ $mail->Subject = 'Transaction Created Successfully'; $mail->isHTML(TRUE); /* Set the mail message body. */ $mail->Body = '<div class="email-background" style="background: #eee;padding: 10px;"> <a href="https://www.safetranzact.com"><center><img src="https://www.safetranzact.com/assets/images/fav.png" style="padding-top:30px;padding-bottom:30px;max-width:100px;height:100px;margin: 0 auto;"></center><a> <div class="email-container" style="max-width: 500px;background: white;font-family: san-serif;margin: 0 auto;overflow: hidden;border-radius: 5px;text-align: center;"> <p style="margin: 20px;font-size: 12px;font-weight: 300;color: #666;line-height: 1.5;text-align:left"> Dear <b>' . $full_name . '</b>,<br/>We believe there is an agreement between you and <b> '. $fullname .' </b>for a transaction. Please see the details of the transaction below</p> <div class="table table-responsive" style="margin-left: 10px;margin-right: 10px;"> <table class="table table-striped table-bordered" style="max-width: 100%;background-color: transparent;border-collapse: collapse;border-spacing: 0;display: table;width: 100%;margin-bottom: 20px;border: 1px solid #ddd;"> <tbody style="display: table-row-group;vertical-align: middle;border-color: inherit;"> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="2" width="100%" style="text-align: center;background: #00bf6f;color: white;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;font-size:20px">Transaction Details <b>'.$transact_no.'</b></td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Title</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$db_cat_category.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Description</td> <td colspan="" width="80%" style="text-align: right;font-size: 12px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$description.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Transaction Link</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$tran_link.'</td> </tr> '.$customerMail.' <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Item Worth/Price</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$price_format.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Charges bearer</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$charges.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Total Charges</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">₦'.$chrg.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Who pay the charges?</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$chrgs.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Buyer Pays</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$buyer_t_pay.'</td> </tr> <tr style="display: table-row;vertical-align: inherit;border-color: inherit;"> <td colspan="" width="20%" style="text-align: left;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">Seller Receives</td> <td colspan="" width="80%" style="text-align: right;font-size: 14px;border: 1px solid #ddd;padding: 8px;line-height: 1.428571429;vertical-align: top;border-top: 1px solid #ddd;">'.$seller_t_receives.'</td> </tr> </tbody> </table> </div> </div> <div class="footer-junk" style="background: none;padding: 20px;font-size: 12px;text-align: center;"> Copyright © Safetranzact '. $year .' All Rights Reserved </div> </div>'; /* Finally send the mail. */ //$mail->send(); if (!$mail->send()){ /* PHPMailer error. */ echo $mail->ErrorInfo; }else{ $output ="<div class=\"alert alert-success\">Transaction has been created successfully</div>"; } //$mail->ClearAllRecipients(); } catch (Exception $e) { /* PHPMailer exception. */ echo $e->errorMessage(); } catch (\Exception $e) { /* PHP exception (note the backslash to select the global namespace Exception class). */ echo $e->getMessage(); } //$mail->ClearAllRecipients(); // //End of First user to received email //Second user to received email // $fullname = $user["firstname"] . " " . $user["lastname"]; $full_name = $fname . " " . $lname; $year = date('Y'); /* Create a new PHPMailer object. Passing TRUE to the constructor enables exceptions. */ $mail = new PHPMailer(TRUE); /* Open the try/catch block. */ try { /* Set the mail sender. */ $mail->setFrom('no-reply@safetranzact.com', 'Safetranzact'); /* Add a recipient. */ $mail->addAddress("$dbemail", "$fullname"); /* Set the subject. */ $mail->Subject = 'Transaction Created Successfully'; $mail->isHTML(TRUE); /* Set the mail message body. */ $mail->Body = '<div class="email-background" style="background: #eee;padding: 10px;"> <a href=""><center><img src="" style="padding-top:30px;padding-bottom:30px;max-width:100px;height:100px;margin: 0 auto;"></center><a> <div class="email-container" style="max-width: 500px;background: white;font-family: san-serif;margin: 0 auto;overflow: hidden;border-radius: 5px;text-align: center;"> <p style="margin: 20px;font-size: 12px;font-weight: 300;color: #666;line-height: 1.5;text-align:left"> Dear ' . $fullname . ',<br/>You just initiated a transaction with title <b>'. $cat_category .'</b> and description <b>'. $description .' to <b>'. $full_name .' </b>Below is the details of the transaction</p> <div class="table table-responsive" style="margin-left: 10px;margin-right: 10px;"> <table class="table table-striped table-bordered" style=" This script works well as far as getting the form information onto the database but for some reason the confirmation email is not being sent to the user. Could someone take a quick look at my script? Please? I've attached the included files as well. I guess I just need another set of eyes to look over this script. It would be much appreciated <?php // Created BY Adam Khoury @ www.developphp.com // let's initialize vars to be printed to page in the HTML section so our script does not return errors // they must be initialized in some server environments $errorMsg = ""; $firstname = ""; $lastname = ""; $country = ""; $state = ""; $city = ""; $zip = ""; $website = ""; $youtube = ""; $email1 = ""; $email2 = ""; $pass1 = ""; $pass2 = ""; // This code runs only if the form submit button is pressed if (isset ($_POST['firstname'])){ /* Example of cleaning variables in a loop $vars = ""; foreach ($_POST as $key => $value) { $value = stripslashes($value); $vars .= "$key = $value<br />"; } print "$vars"; exit(); */ $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $country = $_POST['country']; $state = $_POST['state']; $city = $_POST['city']; $zip = $_POST['zip']; $website = $_POST['website']; $youtube = $_POST['youtube']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; $humancheck = $_POST['humancheck']; $firstname = stripslashes($firstname); $lastname = stripslashes($lastname); $state = stripslashes($state); $city = stripslashes($city); $zip = stripslashes($zip); $website = stripslashes($website); $youtube = stripslashes($youtube); $email1 = stripslashes($email1); $pass1 = stripslashes($pass1); $email2 = stripslashes($email2); $pass2 = stripslashes($pass2); $firstname = strip_tags($firstname); $lastname = strip_tags($lastname); $state = strip_tags($state); $city = strip_tags($city); $zip = strip_tags($zip); $website = strip_tags($website); $youtube = strip_tags($youtube); $email1 = strip_tags($email1); $pass1 = strip_tags($pass1); $email2 = strip_tags($email2); $pass2 = strip_tags($pass2); // Connect to database include_once "connect_to_mysql.php"; $emailCHecker = mysql_real_escape_string($email1); $emailCHecker = eregi_replace("`", "", $emailCHecker); // Database duplicate e-mail check setup for use below in the error handling if else conditionals mysql_select_db("perry100_users", $myConnection); $sql_email_check = mysql_query("SELECT email FROM myMembers WHERE email='$emailCHecker'", $myConnection); $email_check = mysql_num_rows($sql_email_check);// or die(mysql_error()); // Error handling for missing data if ((!$firstname) || (!$lastname) || (!$country) || (!$state) || (!$city) || (!$zip) || (!$email1) || (!$email2) || (!$pass1) || (!$pass2)) { $errorMsg = 'ERROR: You did not submit the following required information:<br /><br />'; if(!$firstname){ $errorMsg .= ' * First Name<br />'; } if(!$lastname){ $errorMsg .= ' * Last Name<br />'; } if(!$country){ $errorMsg .= ' * Country<br />'; } if(!$state){ $errorMsg .= ' * State or Provice<br />'; } if(!$city){ $errorMsg .= ' * City<br />'; } if(!$zip){ $errorMsg .= ' * Postal or Zip Code<br />'; } if(!$email1){ $errorMsg .= ' * Email Address<br />'; } if(!$email2){ $errorMsg .= ' * Confirm Email Address<br />'; } if(!$pass1){ $errorMsg .= ' * Login Password<br />'; } if(!$pass2){ $errorMsg .= ' * Confirm Login Password<br />'; } } else if ($email1 != $email2) { $errorMsg = 'ERROR: Your Email fields below do not match<br />'; } else if ($pass1 != $pass2) { $errorMsg = 'ERROR: Your Password fields below do not match<br />'; } else if ($humancheck != "") { $errorMsg = 'ERROR: The Human Check field must be cleared to be sure you are human<br />'; } else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our database. Please use another.<br />"; } else { // Error handling is ended, process the data and add member to database //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $firstname = mysql_real_escape_string($firstname); $lastname = mysql_real_escape_string($lastname); $state = mysql_real_escape_string($state); $city = mysql_real_escape_string($city); $zip = mysql_real_escape_string($zip); $website = mysql_real_escape_string($website); $youtube = mysql_real_escape_string($youtube); $email1 = mysql_real_escape_string($email1); $pass1 = mysql_real_escape_string($pass1); $firstname = eregi_replace("`", "", $firstname); $lastname = eregi_replace("`", "", $lastname); $state = eregi_replace("`", "", $state); $city = eregi_replace("`", "", $city); $zip = eregi_replace("`", "", $zip); $website = eregi_replace("`", "", $website); $youtube = eregi_replace("`", "", $youtube); $email1 = eregi_replace("`", "", $email1); $pass1 = eregi_replace("`", "", $pass1); $website = eregi_replace("http://", "", $website); $youtube = eregi_replace("http://www.youtube.com/user/", "", $youtube); // Add MD5 Hash to the password variable $db_password = md5($pass1); // Add user info into the database table for the main site table(knirv.com) $sql = mysql_query("INSERT INTO myMembers (firstname, lastname, country, state, city, zip, email, password, sign_up_date, website, youtube) VALUES('$firstname','$lastname','$country','$state','$city','$zip','$email1','$db_password', now(),'$website','$youtube')") or die (mysql_error()); $id = mysql_insert_id(); // Create directory(folder) to hold each user's files(pics, MP3s, etc.) mkdir("members/$id", 0755); //!!!!!!!!!!!!!!!!!!!!!!!!! Email User the activation link !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $myemail = "admin@knirv.com"; $emess = "First Name: $firstname\n"; $emess.= "Last Name: $lastname\n"; $emess.= "Email 1: $email1\n"; $emess.= "Email 2: $email2\n"; $emess.= "City: $city\nState: $state\nZip/Post Code:$zip\n"; $emess.= "Country: $scountry\n"; $emess.= "Phone number 1: $phone1\n"; $emess.= "Phone number 2: $phone2\n"; $emess.= "Phone number 3: $phone3\n"; $emess.= "Comments: $sendmail"; $ehead = "From: $myemail\r\n"; $subj = "Complete knirv.com registration!"; $mailsend=mail("$myemail","$subj","$emess","$ehead"); //Begin HTML Email Message $message = "Hi $firstname, Complete this step to activate your login identity at knirv.com. Click the line below to activate when ready. http://www.knirv.com/activation.php?id=$id&sequence=$db_password If the URL above is not an active link, please copy and paste it into your browser address bar Login after successful activation using your: E-mail Address: $email Password: $password See you on the site! admin@knirv.com"; //end of message unset($_GET['do']); header("Location: thank_you.php"); break; } $msgToUser = "<h2>One Last Step - Activate through Email</h2><h4>OK $firstname, one last step to verify your email identity:</h4><br /> In a moment you will be sent an Activation link to your email address.<br /><br /> <br /> <strong><font color=\"#990000\">VERY IMPORTANT:</font></strong> If you check your email with your host providers default email application, there may be issues with seeing the email contents. If this happens to you and you cannot read the message to activate, download the file and open using a text editor. If you still cannot see the activation link, contact site admin and briefly discuss the issue.<br /><br /> "; include_once 'msgToUser.php'; exit(); } // Close else after duplication checks else { // if the form is not posted with variables, place default empty variables $errorMsg = "Fields marked with an [ * ] are required"; $firstname = ""; $lastname = ""; $country = ""; $state = ""; $city = ""; $zip = ""; $website = ""; $youtube = ""; $email1 = ""; $email2 = ""; $pass1 = ""; $pass2 = ""; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="Kinetic Network" content="Register to knirv.com" /> <meta name="Knirv Registration" content="register, www.knirv.com" /> <meta name="rating" content="General" /> <title>Register Your Account</title> <link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <style type="text/css"> <!-- .style26 {color: #FF0000} .style28 {font-size: 14px} .brightRed { color: #F00; } .textSize_9px { font-size: 9px; } --> </style> <link href="CSS/site_layout.css" rel="stylesheet" type="text/css" /> </head> <body> <?php include_once "header_template.php"; if ($message) echo "<p>$message</p>"; ?> <table width="950" align="center"> <tr> <td width="758"> <blockquote> <h2><br /> Create Your Account Below </h2> </blockquote> <table width="600" align="center" cellpadding="5"> <form action="register.php" method="post" enctype="multipart/form-data"> <tr> <td width="125" class="style7"><div align="center"><strong>Please Do First →</strong></div></td> <td width="447" bgcolor="#FFFFFF">Add <a href="mailto:admin@yknirv.com"><u>admin@knirv.com</u></a> to your email white list or safe sender list now, or else you might not get the activation email that is necessary for logging in successfully. </td> </tr> <tr> <td colspan="2"><font color="#FF0000"><?php print "$errorMsg"; ?></font></td> </tr> <tr> <td align="right" class="alignRt">First Name:<span class="brightRed"> *</span></td> <td><input name="firstname" type="text" class="formFields" id="firstname" value="<?php print "$firstname"; ?>" size="32" maxlength="20" /></td> </tr> <tr> <td align="right" class="alignRt">Last Name:<span class="brightRed"> *</span></td> <td><input name="lastname" type="text" class="formFields" id="lastname" value="<?php print "$lastname"; ?>" size="32" maxlength="20" /></td> </tr> <tr> <td align="right" class="alignRt">Country:<span class="brightRed"> *</span></td> <td> <select name="country" class="formFields"> <option value="<?php print "$country"; ?>"><?php print "$country"; ?></option> <option value="United States of America">United States of America</option> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="American Samoa">American Samoa</option> <option value="Andorra">Andorra</option> <option value="Angola">Angola</option> <option value="Anguilla">Anguilla</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia">Armenia</option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Benin">Benin</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bonaire">Bonaire</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Botswana">Botswana</option> <option value="Brazil">Brazil</option> <option value="British Indian Ocean Ter">British Indian Ocean Ter</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Burkina Faso">Burkina Faso</option> <option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option> <option value="Cameroon">Cameroon</option> <option value="Canada">Canada</option> <option value="Canary Islands">Canary Islands</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Central African Republic">Central African Republic</option> <option value="Chad">Chad</option> <option value="Channel Islands">Channel Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmas Island">Christmas Island</option> <option value="Cocos Island">Cocos Island</option> <option value="Columbia">Columbia</option> <option value="Comoros">Comoros</option> <option value="Congo">Congo</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</option> <option value="Cote D'Ivoire">Cote D'Ivoire</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Curacao">Curacao</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="East Timor">East Timor</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Equatorial Guinea">Equatorial Guinea</option> <option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option> <option value="Ethiopia">Ethiopia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guiana">French Guiana</option> <option value="French Polynesia">French Polynesia</option> <option value="French Southern Ter">French Southern Ter</option> <option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option> <option value="Georgia">Georgia</option> <option value="Germany">Germany</option> <option value="Ghana">Ghana</option> <option value="Gibraltar">Gibraltar</option> <option value="Great Britain">Great Britain</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guam">Guam</option> <option value="Guatemala">Guatemala</option> <option value="Guinea">Guinea</option> <option value="Guyana">Guyana</option> <option value="Haiti">Haiti</option> <option value="Hawaii">Hawaii</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Iran">Iran</option> <option value="Iraq">Iraq</option> <option value="Ireland">Ireland</option> <option value="Isle of Man">Isle of Man</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option> <option value="Korea North">Korea North</option> <option value="Korea South">Korea South</option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Laos">Laos</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option> <option value="Liberia">Liberia</option> <option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macau">Macau</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malaysia">Malaysia</option> <option value="Malawi">Malawi</option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Martinique">Martinique</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mayotte">Mayotte</option> <option value="Mexico">Mexico</option> <option value="Midway Islands">Midway Islands</option> <option value="Moldova">Moldova</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Montserrat">Montserrat</option> <option value="Morocco">Morocco</option> <option value="Mozambique">Mozambique</option> <option value="Myanmar">Myanmar</option> <option value="Nambia">Nambia</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherland Antilles">Netherland Antilles</option> <option value="Netherlands">Netherlands</option> <option value="Nevis">Nevis</option> <option value="New Caledonia">New Caledonia</option> <option value="New Zealand">New Zealand</option> <option value="Nicaragua">Nicaragua</option> <option value="Niger">Niger</option> <option value="Nigeria">Nigeria</option> <option value="Niue">Niue</option> <option value="Norfolk Island">Norfolk Island</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau Island">Palau Island</option> <option value="Palestine">Palestine</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru">Peru</option> <option value="Philippines">Philippines</option> <option value="Pitcairn Island">Pitcairn Island</option> <option value="Poland">Poland</option> <option value="Portugal">Portugal</option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Reunion">Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Rwanda">Rwanda</option> <option value="St Barthelemy">St Barthelemy</option> <option value="St Eustatius">St Eustatius</option> <option value="St Helena">St Helena</option> <option value="St Kitts-Nevis">St Kitts-Nevis</option> <option value="St Lucia">St Lucia</option> <option value="St Maarten">St Maarten</option> <option value="St Pierre and Miquelon">St Pierre and Miquelon</option> <option value="St Vincent and Grenadines">St Vincent and Grenadines</option> <option value="Saipan">Saipan</option> <option value="Samoa">Samoa</option> <option value="Samoa American">Samoa American</option> <option value="San Marino">San Marino</option> <option value="Sao Tome and Principe">Sao Tome and Principe</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Senegal">Senegal</option> <option value="Seychelles">Seychelles</option> <option value="Serbia and Montenegro">Serbia and Montenegro</option> <option value="Sierra Leone">Sierra Leone</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option> <option value="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option> <option value="Swaziland">Swaziland</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Tahiti">Tahiti</option> <option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option> <option value="Tanzania">Tanzania</option> <option value="Thailand">Thailand</option> <option value="Togo">Togo</option> <option value="Tokelau">Tokelau</option> <option value="Tonga">Tonga</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Tunisia">Tunisia</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks and Caicos Is">Turks and Caicos Is</option> <option value="Tuvalu">Tuvalu</option> <option value="Uganda">Uganda</option> <option value="Ukraine">Ukraine</option> <option value="United Arab Emirates">United Arab Emirates</option> <option value="United Kingdom">United Kingdom</option> <option value="United States of America">United States of America</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City State">Vatican City State</option> <option value="Venezuela">Venezuela</option> <option value="Vietnam">Vietnam</option> <option value="Virgin Islands (Brit)">Virgin Islands Brit</option> <option value="Virgin Islands (USA)">Virgin Islands USA</option> <option value="Wake Island">Wake Island</option> <option value="Wallis and Futana Is">Wallis and Futana Is</option> <option value="Yemen">Yemen</option> <option value="Zaire">Zaire</option> <option value="Zambia">Zambia</option> <option value="Zimbabwe">Zimbabwe</option> </select> </td> </tr> <tr> <td align="right" class="alignRt">State/Province: <span class="brightRed">*</span></td> <td><input name="state" type="text" class="formFields" id="state" value="<?php print "$state"; ?>" size="32" maxlength="36" /></td> </tr> <tr> <td align="right" class="alignRt">City: <span class="brightRed">*</span></td> <td><input name="city" type="text" class="formFields" id="city" value="<?php print "$city"; ?>" size="32" maxlength="36" /></td> </tr> <tr> <td align="right" class="alignRt">Postal / Zip Code: <span class="brightRed">*</span></td> <td><input name="zip" type="text" class="formFields" id="zip" value="<?php print "$zip"; ?>" size="32" maxlength="24" /></td> </tr> <tr> <td align="right" class="alignRt">Website:</td> <td><strong>http://</strong> <input name="website" type="text" class="formFields" id="website" value="<?php print "$website"; ?>" size="40" maxlength="88" /></td> </tr> <tr> <td align="right" class="alignRt">Youtube Channel:</td> <td><strong>http://www.youtube.com/user/</strong> <input name="youtube" type="text" class="formFields" id="youtube" value="<?php print "$youtube"; ?>" size="32" maxlength="88" /></td> </tr> <tr> <td align="right" class="alignRt">Email Address: <span class="brightRed">*</span></td> <td><input name="email1" type="text" class="formFields" id="email1" value="<?php print "$email1"; ?>" size="32" maxlength="48" /></td> </tr> <tr> <td align="right" class="alignRt">Confirm Email:<span class="brightRed"> *</span></td> <td><input name="email2" type="text" class="formFields" id="email2" value="<?php print "$email2"; ?>" size="32" maxlength="48" /></td> </tr> <tr> <td align="right" class="alignRt">Create Password:<span class="brightRed"> *</span></td> <td><input name="pass1" type="password" class="formFields" id="pass1" maxlength="16" /> <span class="textSize_9px"><span class="greyColor">Alphanumeric Characters Only</span></span></td> </tr> <tr> <td align="right" class="alignRt">Confirm Password:<span class="brightRed"> *</span></td> <td><input name="pass2" type="password" class="formFields" id="pass2" maxlength="16" /> <span class="textSize_9px"><span class="greyColor">Alphanumeric Characters Only</span></span></td> </tr> <tr> <td align="right" class="alignRt"><br /> Human Check: <span class="brightRed">*</span></td> <td><br /> <input name="humancheck" type="text" class="formFields" id="humancheck" value="Please remove all of this text" size="38" maxlength="32" /> </td> </tr> <tr> <td> </td> <td><p><br /> <input type="submit" name="Submit3" value="Submit Form" /> </p></td> </tr> </form> </table> <br /> <br /></td> <td width="180" valign="top"><?php include_once "right_AD_template.php"; ?></td> </tr> </table> <?php include_once "footer_template.php"; ?> </body> </html> <script type="text/javascript"> Dear all, Hopefully someone can help me out with this. I have a HTML form wich contains basic textfields en checkboxes. Beyond that i have a row with some dropdowns, but one of these fields in the row is a file field. Also, the visitor is able to add a new row, when the user clicks add row, a new row with the same fields including a new file field appears. This can be done as much as the user likes. The fiel field is optional though, it doesn't need to be filled. All my textfields, checkboxes and dropdowns are coming through email nicely. Only thing that isn't coming my way are the files i attach. My form (stripped but functional) can be seen here http://www.multisearch.info/test/form_test.html For the file fields i take it you need an array wich i have put in the form Code: [Select] <input type="file" name="fileupload[]"> In my PHP wich handles the form i have this wich should handle the images, but this is not working Code: [Select] if(isset($_POST['submit'])) { for($i=0;$i<count($_FILES['fileupload']);$i++) { print $_FILES['fileupload']['name'][$i]."<br />"; } } I hope someone sees something i am missing. Kind regards, Jeroen Code: [Select] <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $dropdown = $_POST['dropdown']; $formcontent=" From: $firstname \n Surname: $lastname \n Email: $email \n Dropdown: $dropdown"; $recipient = "martin@sittingspiritually.co.uk, siobhan@sittingspiritually.co.uk"; $subject = "Newsletter Sign Up"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); if ( mail($recipient, $subject, $formcontent, $mailheader) ){ header('Location: http://www.sittingspiritually.co.uk/thankyou.php'); } else { die ("error"); } ?> I have recently created a small snippet of php code for posting mail and it's sweet apart from 1 thing. I have two email addresses in the recipient section. It only sends to the last name in the list. Is this because i have written recipient? Should it be recipients? I need this mail to be delivered to both of the email addresses. I'm sure it's simple for someone with expert knowledge. Thanks in advance for any help.
Hello. I activate the Payment Gateway Platform (by Redsys in Spain), and it works fine asking you for card number and it goes through correctly and says PAYMENT OK, but the notification.PHP FILE does not work. Could my server (SSL) configuration be the problem? or is it the CODE? Any help about this, please, would be highly appreciated. Thank you. Part of the Nofication.php code is: __________________________________________________________________________________
<?php $handle = fopen("_redsys.log", "a");
require_once("include/dbcommon.php"); $miObj = new RedsysAPI;
$version = postvalue("Ds_SignatureVersion");
// $version = "HMAC_SHA256_V1";
$claveModuloAdmin = 'sq7HjrUOBfKmC576ILgskD5srU870gJ7';
if ($signatureCalculada === $signatureRecibida && $res["Ds_AuthorisationCode"]!="++++++" && !isset($res["Ds_ErrorCode"]) {
$sql = "SELECT Espacio FROM Espacios WHERE Id_Espacio=" . $values["Id_Espacio"];
// echo '<img src="data:image/jpeg;base64,'.$imageData.'">';
_______________________________________________________________________________________________ I have phpmailer on a website and after clicking send, it goes to the forms action page and don't seem to redirect to the enquiry confirmation page, the forms action page is a blank white page which am guessing is correct as it's PHP coding but thought it should redirect. I don't get any errors showing what the issue is. I have the phpmailer uploaded onto the FTP server and has the class.phpmailer.php file inside the phpmailer folder. The client has their email going through office365. Below is the code I have + <?php ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); //index.php $error = ''; $name = ''; $email = ''; $subject = ''; $message = ''; function clean_text($string) { $string = trim($string); $string = stripslashes($string); $string = htmlspecialchars($string); return $string; } if(isset($_POST["submit"])) { if(empty($_POST["name"])) { $error .= '<p><label class="text-danger">Please Enter your Name</label></p>'; } else { $name = clean_text($_POST["name"]); if(!preg_match("/^[a-zA-Z ]*$/",$name)) { $error .= '<p><label class="text-danger">Only letters and white space allowed</label></p>'; } } if(empty($_POST["email"])) { $error .= '<p><label class="text-danger">Please Enter your Email</label></p>'; } else { $email = clean_text($_POST["email"]); if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error .= '<p><label class="text-danger">Invalid email format</label></p>'; } } if(empty($_POST["subject"])) { $error .= '<p><label class="text-danger">Subject is required</label></p>'; } else { $subject = clean_text($_POST["subject"]); } if(empty($_POST["message"])) { $error .= '<p><label class="text-danger">Message is required</label></p>'; } else { $message = clean_text($_POST["message"]); } if($error == '') { require 'phpmailer/class.phpmailer.php'; $mail = new PHPMailer; $mail->SMTPDebug = 2; $mail->IsSMTP(); //Sets Mailer to send message using SMTP $mail->Host = 'smtp.office365.com'; //Sets the SMTP hosts $mail->Port = '587'; //Sets the default SMTP server port $mail->SMTPSecure = 'tls'; //Sets connection prefix. Options are "", "ssl" or "tls" $mail->SMTPAuth = true; //Sets SMTP authentication. Utilizes the Username and Password variables $mail->Username = 'email@domain.co.uk'; //Sets SMTP username $mail->Password = 'password'; //Sets SMTP password $mail->From = $_POST["email"]; //Sets the From email address for the message $mail->FromName = $_POST["name"]; //Sets the From name of the message $mail->AddAddress('email@domain.co.uk', 'Name');//Adds a "To" address $mail->AddCC($_POST["email"], $_POST["name"]); //Adds a "Cc" address $mail->WordWrap = 50; //Sets word wrapping on the body of the message to a given number of characters $mail->IsHTML(true); //Sets message type to HTML $mail->Subject = "New Website Enquiry"; //Sets the Subject of the message $mail->Body = "Name: " . $_POST["name"] . "<br><br>" . "Email: " . $_POST["email"] . "<br><br>" . "Subject: " . $_POST["subject"] . "<br><br>" . "Message: " . "<br>" . $_POST["message"]; //An HTML or plain text message body if (!$mail->Send()) //Send an Email. Return true on success or false on error { header('Location: https://www.domain.co.uk/enquiry-confirmation.php'); } else { $error = '<label class="text-danger">There is an Error</label>'; } $name = ''; $email = ''; $subject = ''; $message = ''; } } ?>
Alright so I have 3 pages. Signup, Password reset and Send message. All three pages/forms email to the recipient.
So far my test have only been with hotmail and gmail.
All emails go through for hotmail accounts. They show up in the hotmail.
All emails DO go through for gmail accounts. But they don't show up in the gmail. The only page that gmail is able to receive emails from is "send message". The emails derived from that send message show up in gmail. The other two don't.
There are not errors on the server side that show up. It clearly shows emails being sent.
Does anyone have a clue why this is happening?
Edited by man5, 23 August 2014 - 03:48 PM. So I am trying to use PHP mailer on my site however it doesn't post to the email Here is the code: Top: <?php
use PHPMailer\PHPMailer\PHPMailer;
require 'vendor/phpmailer/phpmailer/src/Exception.php'; Where it sends: require 'vendor/autoload.php';
//Instantiation and passing `true` enables exceptions
I have tried everything but it still won't post. Hi there, i am trying to send a html using phpMailer and am following this tutorial: http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html I have managed to send an email just fine but when i try to add html to it it doesn't work! I get this message: Mail sent! Fatal error: Call to undefined method FreakMailer::Body() in /hermes/waloraweb018/b1267/moo.organicgrowshopcouk/testemail.php on line 44 This is the code I'm using: <?php // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); // instantiate the class $mailer = new FreakMailer(); // Set the subject $mailer->Subject = 'This is a test'; // Body $mailer->Body = 'This is a test of my mail system!'; // Add an address to send to. $mailer->AddAddress('info@organicgrowshop.co.uk', 'Matt Johnson'); if(!$mailer->Send()) { echo 'There was a problem sending this mail!'; } else { echo 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); $htmlBody = '<html> <head> <title>My HTML Email</title> </head> <body> <br /> <h2>PHP Freaks Rules!</h2> <p>We invite you to visit <a href="http://www.phpfreaks.com" title="PHP Freaks">PHP Freaks.com</a> for a loving community of PHP Developers who enjoy helping each other learn the language!</p> <p>Sincerely,<br /> PHP Freaks Staff</p>'; $mailer->Body($htmlBody); $mailer->isHTML(true); // Send the E-Mail ?> How do i define method Body() ? Do i need to change something in the phpmailer.class.php file? Sorry if i sound like a complete n00b. I have been taking a crash course trying to learn php/html/javascript/jquery and am probably asking a fairly simple question. I installed phpmailer recently and have been able to send mail with attachments without a problem, but I am trying to make the body of the email HTML. Unfortunately each attempt the formatting is not preserved. I tried copying the same style that I use when I generate the same report to a web page, but it isnt translating to an html email. I have included the code that is relevant. Any glaring oversights? $htmlBody = '<html><head><title>Calls Yesterday</title></head>'; $htmlBody .='<style type="text/css"> body { font-family: Arial, Helvetica, sans-serif; font-size: 16px; } th { font-weight: bold; text-align: left; } td, th { padding: 15px 15px 15px 15px; width: 75px; vertical-align: top; text-align: left; } .outputData2 { margin-left: -10px; margin-right: -10px; width: 500px; } .outputData2 th { white-space: nowrap; text-align: left; padding-right: 10px; } .outputData2 td { white-space: nowrap; text-align: left; } a { text-decoration: none; color: #000; } strong { font-weight: bold; } </style> <br />'; $htmlBody .= '<div style="width: 640px; height: 500px; margin: 10px 0 0 0; padding: 10px; border: 1px solid #e3e3e3; overflow: auto" ><br />'; $htmlBody .= '<table cellpadding="0" cellspacing="0" align="center" class="outputdata2"><br />'; // $htmlBody .= '<table cellpadding="0" cellspacing="0" th="font-weight: bold; width: 25px; padding: 5px,5px,5px,5px; padding-right: 10px; text-align: left; white-space: nowrap;" td="padding: 5px,5px,5px,5px; width: 25px; text-align: left; vertical-align: top; white-space: nowrap;">'; $htmlBody .= '<th>Campaign</th><th>Number of Calls</th><th>Total Call Duration</th><th>Avg Call Duration</th><th>Call Status</th><br />'; // Setup mail class, recipients and body $mailer->AddAddress('me@mail.com', 'PHP Novice'); $mailer->Subject = 'Calls on '.$currentDate.''; $mailer->Body = $htmlBody; $mailer->IsHTML(true); $mailer->AltBody = $textBody; $mailer->AddAttachment($_SERVER['DOCUMENT_ROOT'].'/dashboardOld/campaignFiles/'.$prevClient."_".$currentDate.'.csv', ''.$prevClient."_".$currentDate.'.csv'); $mailer->AddAttachment($_SERVER['DOCUMENT_ROOT'].'/dashboardOld/campaignFiles/'.$prevClient."_".$currentDate.'.json', ''.$prevClient."_".$currentDate.'.json'); $mailer->Send(); $mailer->ClearAddresses(); $mailer->ClearAttachments(); $mailer->IsHTML(false); I even resorted to include the style sheet in what i passed to phpmailer because the formatting wasn't working when i coded the html settings withing $htmlBody originally. Any help would be appreciated. Thanks, Jeff I am sending emails using PHPMailer. My configuration is below.
When adding a link to the message, should I use anchor tags? Both seem to work. What is the implication to recipients who are not using HTML email?
On a side note, if anything below seems wrong, please let me know.
Thanks
$msg='<p>Hello</p><p>Link: http://phpmailer.worxware.com/</p><p>Link: http://phpmailer.worxware.com</p><a href="http://phpmailer.worxware.com">http://phpmailer.worxware.com</a>'; $mail = new myPHPMailer(true); $mail->AddReplyTo('myEmail@xxx.com', 'Michael Reed'); $mail->SetFrom('myEmail@xxx.com', 'Michael Reed'); $mail->AddAddress('johndoe@xxx.com', 'John Doe'); $mail->Subject = "Here is your email"; //AltBody property need not be sent since PHPMailer will create an alternate automatically $mail->MsgHTML($message); return ($mail->Send()); class myPHPMailer extends PHPMailer { public function __construct($allow_exceptions=false){ $this->isSMTP(); $this->SMTPDebug = 0; $this->Host = "smtp.gmail.com"; $this->Port = 587; $this->SMTPSecure='tls'; // sets the prefix to the server. Used for gmail only. $this->SMTPAuth = true; $this->Username = 'xxx'; $this->Password = 'xxx'; } } Hello, I'm using phpmailer for this job, and what I want is that in first mail user gets only text and in second he gets text with attachment. But code below is only sending me the mail with attachment(second mail), what is cosing this problem? Here's the code Code: [Select] for ($i=0; $i<2; $i++) { if (!class_exists("phpmailer")) { require("PHPMailer/class.phpmailer.php"); } if ($price != 0 ) { $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->From = "domain@d.com"; $mail->FromName = "Company"; $mail->AddAddress($email, ""); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = "Subjcet"; $mail->Body = $content; } if ($i == 1 || $price == 0 ) { //require("PHPMailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->From = "domain@d.com"; $mail->FromName = "Company"; $mail->AddAddress($email, ""); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = "Subjcet"; $mail->Addattachment ("file/patch".$fileName, ); // patch and name of an attachment } } |