php - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of php.php

  1. <?php
  2. require 'PHPMailerAutoload.php';
  3.  
  4. $mail = new PHPMailer;
  5.  
  6. //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  7.  
  8. $mail->isSMTP();                                      // Set mailer to use SMTP
  9. $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  10. $mail->SMTPAuth = true;                               // Enable SMTP authentication
  11. $mail->Username = '[email protected]';                 // SMTP username
  12. $mail->Password = 'yanis27nadia';                           // SMTP password
  13. $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  14. $mail->Port = 587;                                    // TCP port to connect to
  15.  
  16. $mail->setFrom('[email protected]');
  17. $mail->addAddress('[email protected]'); // Name is optional
  18. $mail->addReplyTo('[email protected]');
  19.  
  20. $mail->isHTML(true);                                  // Set email format to HTML
  21. $mail ->SMTPDebug = 3;
  22.  
  23. $mail->Subject = 'Here is the subject';
  24. $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  25. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  26.  
  27.  
  28.  
  29.  
  30. if(!$mail->send()) {
  31.     echo 'Message could not be sent.';
  32.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  33. } else {
  34.     echo 'Message has been sent';
  35. }
  36.  
  37. ?>
File Description
  • php
  • PHP Code
  • 23 Nov-2020
  • 1.34 Kb
You can Share it: