PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/views/Catagory/email.php

https://gitlab.com/Iftekhar_ramim/stock_management
PHP | 105 lines | 64 code | 7 blank | 34 comment | 2 complexity | f132b5005976162e0b945240869f30fb MD5 | raw file
  1. <?php
  2. require_once ('../../vendor/autoload.php');
  3. use App\Bitm\Catagory\Catagory;
  4. $email= $_POST['email'];
  5. //echo $email;
  6. //die();
  7. $obj= new Catagory();
  8. $allData= $obj->index();
  9. $trs="";
  10. $sl=0;
  11. foreach($allData as $data):
  12. $sl++;
  13. $trs.="<tr>";
  14. $trs.="<td>$sl</td>";
  15. $trs.="<td>".$data['id']."</td>";
  16. $trs.="<td>".$data['cat_name']."</td>";
  17. $trs.="<td>".$data['status']."</td>";
  18. $trs.="</tr>";
  19. endforeach;
  20. $html=<<<EOD
  21. <!DOCTYPE html>
  22. <html>
  23. <head>
  24. </head>
  25. <body>
  26. <div class="container">
  27. <h2>Book List</h2>
  28. <table class="table">
  29. <thead>
  30. <tr>
  31. <th>SL#</th>
  32. <th>ID</th>
  33. <th>Category name</th>
  34. <th>Status</th>
  35. </tr>
  36. </thead>
  37. <tbody>
  38. $trs
  39. </tbody>
  40. </table>
  41. </body>
  42. </html>
  43. EOD;
  44. /**
  45. * This example shows settings to use when sending via Google's Gmail servers.
  46. */
  47. //SMTP needs accurate times, and the PHP time zone MUST be set
  48. //This should be done in your php.ini, but this is how to do it if you don't have access to that
  49. date_default_timezone_set('Etc/UTC');
  50. require ('../../vendor/phpmailer/phpmailer/class.phpmailer.php');
  51. //Create a new PHPMailer instance
  52. $mail = new PHPMailer;
  53. //Tell PHPMailer to use SMTP
  54. $mail->isSMTP();
  55. //Enable SMTP debugging
  56. // 0 = off (for production use)
  57. // 1 = client messages
  58. // 2 = client and server messages
  59. $mail->SMTPDebug = 0;
  60. //Ask for HTML-friendly debug output
  61. $mail->Debugoutput = 'html';
  62. //Set the hostname of the mail server
  63. $mail->Host = 'smtp.gmail.com';
  64. // use
  65. // $mail->Host = gethostbyname('smtp.gmail.com');
  66. // if your network does not support SMTP over IPv6
  67. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  68. $mail->Port = 587;
  69. //Set the encryption system to use - ssl (deprecated) or tls
  70. $mail->SMTPSecure = 'tls';
  71. //Whether to use SMTP authentication
  72. $mail->SMTPAuth = true;
  73. //Username to use for SMTP authentication - use full email address for gmail
  74. $mail->Username = "linx.creative@gmail.com";
  75. //Password to use for SMTP authentication
  76. $mail->Password = "janina123";
  77. //Set who the message is to be sent from
  78. $mail->setFrom('labexam8@example.com', 'First Last');
  79. //Set an alternative reply-to address
  80. $mail->addReplyTo('replyto@example.com', 'First Last');
  81. //Set who the message is to be sent to
  82. $mail->addAddress($email, 'Smart Doe');
  83. //Set the subject line
  84. $mail->Subject = 'All data Email';
  85. //Read an HTML message body from an external file, convert referenced images to embedded,
  86. //convert HTML into a basic plain-text alternative body
  87. //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  88. //Replace the plain text body with one created manually
  89. $mail->AltBody = 'This is a plain-text message body';
  90. //Attach an image file
  91. //$mail->addAttachment('images/phpmailer_mini.png');
  92. //send the message, check for errors
  93. $mail->Body=$html;
  94. if (!$mail->send()) {
  95. echo "Mailer Error: " . $mail->ErrorInfo;
  96. } else {
  97. echo "Message sent!";
  98. }