|
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
6 | 6 | <title>Send Mail</title> |
7 | 7 | <link rel="stylesheet" href="" /> |
| 8 | + <link |
| 9 | + rel="stylesheet" |
| 10 | + href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" |
| 11 | + /> |
8 | 12 | </head> |
9 | | - <body></body> |
| 13 | + <body> |
| 14 | + <div class="container"> |
| 15 | + <div class="row"> |
| 16 | + <div class="col-md-4 offset-md-4 mail-form"> |
| 17 | + <h2 class="text-center">Send Message</h2> |
| 18 | + <p class="text-center">Send mail to anyone from LocalHost</p> |
| 19 | + <?php |
| 20 | + |
| 21 | + $recipient = ""; |
| 22 | + |
| 23 | + if(isset($_POST['send'])){ |
| 24 | + $recipient = $_POST['email']; |
| 25 | + $subject = $_POST['subject']; |
| 26 | + $message = $_POST['message']; |
| 27 | + $sender = "From: [email protected]"; |
| 28 | + if(empty($recipient) || empty($subject) || empty($message)){ |
| 29 | + ?> |
| 30 | + |
| 31 | + <div class="alert alert-danger text-center"> |
| 32 | + <?php echo 'All inputs are required' ?> |
| 33 | + </div> |
| 34 | + <?php }else{ |
| 35 | + if(mail($recipient, $subject, $message, $sender)) |
| 36 | + } ?> |
| 37 | + |
| 38 | + <div class="alert alert-danger text-center"> |
| 39 | + <?php echo "Failed while sending your mail!" ?> |
| 40 | + </div> |
| 41 | + <?php |
| 42 | + } |
| 43 | + } |
| 44 | + } |
| 45 | + ?> |
| 46 | + <form action="mail.php" method="POST"> |
| 47 | + <div class="form-group"> |
| 48 | + <input |
| 49 | + class="form-control" |
| 50 | + name="email" |
| 51 | + type="email" |
| 52 | + placeholder="Recipients" |
| 53 | + value="<?php echo $recipient ?>" |
| 54 | + /> |
| 55 | + </div> |
| 56 | + <div class="form-group"> |
| 57 | + <input |
| 58 | + class="form-control" |
| 59 | + name="subject" |
| 60 | + type="text" |
| 61 | + placeholder="Subject" |
| 62 | + /> |
| 63 | + </div> |
| 64 | + <div class="form-group"> |
| 65 | + <!-- --> |
| 66 | + </div> |
| 67 | + <div class="form-group"> |
| 68 | + <input |
| 69 | + class="form-control button btn-primary" |
| 70 | + type="submit" |
| 71 | + name="send" |
| 72 | + value="Send" |
| 73 | + placeholder="Subject" |
| 74 | + /> |
| 75 | + </div> |
| 76 | + </form> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + </body> |
10 | 81 | </html> |
0 commit comments