Jump to content

Bar2012

New Members
  • Posts

    1
  • Joined

  • Last visited

Bar2012's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi All - I designed a webpage hosted by GoDaddy and cannot get the php contact form to work correctly. I am using the following php script: <?php //Import PHPMailer classes into the global namespace use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; require_once 'vendor/autoload.php'; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = 'localhost'; $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'myemailaddress'; // SMTP username $mail->Password = 'mypassword'; // SMTP password $mail->SMTPAutoTLS = false; $mail->Port = 25; //SMTP port //Recipients $mail->setFrom('from@example.com', 'Mailer'); $mail->addAddress('recipient1@example.net', 'Joe User'); // Add a recipient $mail->addAddress('recipient2@example.com'); // Name is optional $mail->addReplyTo('info@example.com', 'Information'); $mail->addCC('cc@example.com'); $mail->addBCC('bcc@example.com'); // Content if (isset($_POST['contact'])) { $name = $_POST['username']; $email = $_POST['useremail']; $subject = $_POST['subject']; $usermessage = $_POST['message']; $message ="Name = ". $name . "\r\n Email = " . $email . "\r\n Subject = " . $subject . "\r\n Message =" . $usermessage; // Attachments $mail->send(); if (!$mail->send()) { echo 'Email not sent an error was encountered: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } } ...along with the following html code: <form class="p-5 bg-white" action="contact.php" method="POST" enctype="multipart/form-data" onsubmit="return validateContactForm()"> <div class="margin-t-50"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="username">Name </label> <input type="text" class="form-control" id="username" placeholder="Your Name" required name="name" /> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="useremail">Email address </label> <input type="email" class="form-control" id="useremail" placeholder="Your Email" required name="email" /> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="subject">Subject </label> <input type="text" class="form-control" id="subject" placeholder="Your Subject.." required name="subject" /> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="message">Message </label> <textarea class="form-control" rows="5" id="message" placeholder="Your Message...." required name="message" /></textarea> </div> </div> </div> <div class="row"> <div class="col-sm-12 text-left"> <div class="custom-file-upload"> <!--<label for="file">File: </label>--> <input type="file" id="formFile" name="file" /> <span class="file-type-restrction">Upload only PDF or DOC file</span> </div> </div> <div class="col-sm-12 text-right"> <input type="submit" value="Submit" name="contact" class="btn btn-primary btn-md text-white"> </div> </div> </div> <div id="statusMessage"> <?php if (! empty($message)) { ?> <p class='<?php echo $type; ?>Message'><?php echo $message; ?></p> <?php } ?> </form> I appreciate any recommendations or thoughts. I previously contacted Godaddy, and the tech support was unable to assist, other than by providing the port address. Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.