123 - 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 123.php

  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. use PHPMailer\PHPMailer\SMTP;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6. //Load Composer's autoloader
  7. require 'vendor/autoload.php';
  8.  
  9. ?><!DOCTYPE html>
  10. <html>
  11.  <head>
  12.   <meta charset="utf-8">
  13.    <meta name="viewport" content="width=device-width, initial-scale=1">
  14.    <title>yahoo_Mailer</title>
  15. <link ref="stylesheet" type="text/css" href="style.css">
  16.   </head>
  17. <body>
  18.   <div class="container">
  19.       <?php
  20.       if(isset($_POST['submit_form']))
  21.       {
  22.               echo $to=$_POST['to'];
  23.               $subject=$_POST['subject'];
  24.               $msg=$_POST['msg'];
  25.               $name=$_POST['name'];
  26.               $mail = new PHPMailer(true);
  27.  
  28. try {
  29.     //Server settings
  30.     $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
  31.     $mail->isSMTP();                                            //Send using SMTP
  32.     $mail->Host       = 'cpl27.main-hosting.eu';                     //Set the SMTP server to send through
  33.     $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
  34.     $mail->Username   = '[email protected]';                     //SMTP username
  35.     $mail->Password   = '}{Xp[bb8@cKf';                               //SMTP password
  36.     $mail->SMTPSecure = 'tls';            //Enable implicit TLS encryption
  37.     $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
  38.  
  39.     //Recipients
  40.     $mail->setFrom('[email protected]', 'ssns media');
  41.     $mail->addAddress($to,$name);     //Add a recipient
  42.    //Name is optional
  43.     $mail->addReplyTo('[email protected]', 'Yahoo_legal');
  44.     //$mail->addCC('[email protected]');
  45.     //$mail->addBCC('[email protected]');
  46.  
  47.     //Attachments
  48.     //$mail->addAttachment('/var/tmp/file.tar.gz');         //Add attachments
  49.     //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    //Optional name
  50.  
  51.     //Content
  52.     $mail->isHTML(true);                                  //Set email format to HTML
  53.     $mail->Subject = $subject;
  54.     $mail->Body    = $msg;
  55.     //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  56.  
  57.     $mail->send();
  58.     echo 'Message has been sent';
  59. } catch (Exception $e) {
  60.     echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
  61. }
  62.       }
  63.       ?>
  64.     <h2>Email Sending for Yahoo</h2>
  65.     <form action="" method="POST">
  66.       <label> To Email :- </label>
  67.       <input type="text" name="to" class="form-control" required>
  68.      <label> From Name :- </label>
  69.       <input type="text" name="Name" class="form-control" required>
  70.       <label> Subject Line :- </label>
  71.       <input type="Subject" name="Subject" class="form-control" required>
  72.       <label>Html Body :- </label>
  73.       <textarea name="msg" cols="10" rows="5"type="text" name="Name" class="form-control" required>
  74. </textarea><br /><br />
  75.  
  76. <input type="submit" name="submit_form" value="send">
  77. </form>
  78. </body>
  79. <html>
File Description
  • 123
  • PHP Code
  • 03 Jan-2023
  • 2.96 Kb
You can Share it: