PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/src/admin_panel_dashboard/mail_owner.php

https://gitlab.com/shaon2016/bidwarbd
PHP | 110 lines | 60 code | 17 blank | 33 comment | 0 complexity | a9208e44aefa37bdea69afc1887a0519 MD5 | raw file
  1. <?php
  2. session_start();
  3. include_once ('../../vendor/autoload.php');
  4. require '../../vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
  5. use App\BidWarBd\User;
  6. use App\BidWarBd\Item;
  7. $user = new User();
  8. $user->prepare($_GET);
  9. $getBidderHeighstInfo = $user->gettingDataForSendingEmail();
  10. //var_dump($getBidderHeighstInfo);
  11. $item = new Item();
  12. $item->prepare($_GET);
  13. $singleProduct = $item->singleProduct();
  14. //var_dump($singleProduct); die();
  15. $owner_name = $singleProduct['name'];
  16. $owner_email = $singleProduct['email'];
  17. $owner_mobile = $singleProduct['mobile'];
  18. //var_dump($owner_name); die();
  19. $heighst_bidder_name = $getBidderHeighstInfo['heighst_bidder_name'];
  20. $heighst_bidder_email = $getBidderHeighstInfo['heighst_bidder_email'];
  21. $heighst_bidder_mobile = $getBidderHeighstInfo['heighst_bidder_mobile'];
  22. $bid_amount = $getBidderHeighstInfo['bid_amount'];
  23. //var_dump($_SESSION['owner_name']); die();
  24. /**
  25. * This example shows settings to use when sending via Google's Gmail servers.
  26. */
  27. //SMTP needs accurate times, and the PHP time zone MUST be set
  28. //This should be done in your php.ini, but this is how to do it if you don't have access to that
  29. date_default_timezone_set('Etc/UTC');
  30. //Create a new PHPMailer instance
  31. $mail = new PHPMailer;
  32. //Tell PHPMailer to use SMTP
  33. $mail->isSMTP();
  34. //Enable SMTP debugging
  35. // 0 = off (for production use)
  36. // 1 = client messages
  37. // 2 = client and server messages
  38. $mail->SMTPDebug =0;
  39. //Ask for HTML-friendly debug output
  40. $mail->Debugoutput = 'html';
  41. //Set the hostname of the mail server
  42. $mail->Host = 'smtp.gmail.com';
  43. // use
  44. // $mail->Host = gethostbyname('smtp.gmail.com');
  45. // if your network does not support SMTP over IPv6
  46. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  47. $mail->Port = 587;
  48. //Set the encryption system to use - ssl (deprecated) or tls
  49. $mail->SMTPSecure = 'tls';
  50. //Whether to use SMTP authentication
  51. $mail->SMTPAuth = true;
  52. $mail->SMTPOptions = array(
  53. 'ssl' => array(
  54. 'verify_peer' => false,
  55. 'verify_peer_name' => false,
  56. 'allow_self_signed' => true
  57. )
  58. );
  59. //Username to use for SMTP authentication - use full email address for gmail
  60. $mail->Username = "php.mail.practice@gmail.com";
  61. //Password to use for SMTP authentication
  62. $mail->Password = "php12345";
  63. //Set who the message is to be sent from
  64. $mail->setFrom('php.mail.practice@gmail.com', 'BidWarBD');
  65. //Set an alternative reply-to address
  66. $mail->addReplyTo('replyto@example.com', 'First Last');
  67. //Set who the message is to be sent to
  68. $mail->addAddress($owner_email, $owner_name);
  69. //Set the subject line
  70. $mail->Subject = 'Product Expire date crossed';
  71. //Read an HTML message body from an external file, convert referenced images to embedded,
  72. //convert HTML into a basic plain-text alternative body
  73. //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  74. //Replace the plain text body with one created manually
  75. $mail->AltBody = 'This is a plain-text message body';
  76. $body = "Your product date expired. Bid winner's name: ". $heighst_bidder_name. "<br>"
  77. . " Bid winner's mobile number: ". $heighst_bidder_mobile. "<br>".
  78. " Bid Winner's email: ". $heighst_bidder_email."<br>".
  79. " Heighst bid: ". $bid_amount ."<br>";
  80. //var_dump($body); die();
  81. $mail->Body= $body;
  82. //Attach an image file
  83. //$mail->addAttachment('images/phpmailer_mini.png');
  84. //send the message, check for errors
  85. if (!$mail->send()) {
  86. echo "Mailer Error: " . $mail->ErrorInfo;
  87. } else {
  88. echo "Message sent!";
  89. }