Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The code below retrieves all the customer info from the database including customers email addresses.
- <?php
- while ($row = $result->fetch_assoc()){
- print "<tr>";
- print "<td>" . $row['TransactionID'] . "</td>";
- print "<td>" .$row['ItemName']."<br>" ."</td>";
- print "<td>" .$row['ItemQTY']."<br>" ."</td>";
- print "<td>" . $row['ItemAmount'] . "</td>";
- print "<td>" . $row['BuyerEmail'] . "</td>";
- print "<td ><a href='#sendemail'>Process</a></td>"; //Once this link is clicked, it should take me to the next code send an email the retrieved email.
- print "</tr>";
- }
- $mysqli->close();
- ?>
- // The code below should trigger once i click "Process" and send an email to the customer.
- if (isset($_GET['sendemail'])){
- require 'PHPMailer/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- SMTP servers
- $mail->SMTPAuth = true;
- authentication
- $mail->Username = '****@gmail.com';
- $mail->Password = '********';
- $mail->SMTPSecure = 'tls';
- `ssl` also accepted
- $mail->Port = 587;
- $mail->setFrom('****@gmail.com', 'RANDOMNAME');
- $mail->addReplyTo('****@gmail.com', 'RANDOMNAME');
- $mail->addAddress('BuyerEmail');
- $mail->isHTML(true);
- $bodyContent = '<h1>Our Valued Customer,</h1>';
- $bodyContent .= '<p>Your Order is ready for pick up!</p>';
- $mail->Subject = 'RANDOMNAME';
- $mail->Body = $bodyContent;
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
- runsendemail();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement