saya coba edit ulang formemail.html dan sendemail.php
===== form.html =====
<form method="post" action="sendemail.php">
Email: <input name="email" id="email" type="text" /><br />
Message:<br />
<textarea name="message" id="message" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
==============================
==========sendemail.php=============
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
// here we use the php mail function
// to send an email to:
//
[email protected]
mail( "
[email protected]", "Feedback Form Results",$message, "From: $email" );
?>
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.ayaxx.co.id'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '
[email protected]'; // SMTP username
$mail->Password = '***********'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('
[email protected]', 'Web visitor');
$mail->addAddress('
[email protected]', 'Info'); // Add a recipient
$mail->addAddress(''); // Name is optional
$mail->addReplyTo('
[email protected]', 'Information');
$mail->addCC('
[email protected]');
$mail->addBCC('
[email protected]');
//Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
======================end======================
begitu saya mencoba melalui contact form nya error dengan messages
"
Warning: mail() has been disabled for security reasons in
/home/gugvfylt/public_html/sendemail.php on line
10
// Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; //Load Composer's autoloader require 'vendor/autoload.php'; $mail = new PHPMailer(true); // Passing `true` enables exceptions try { //Server settings $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'mail.ayaxx.co.id'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '
[email protected]'; // SMTP username $mail->Password = 'Pundarika1996'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to //Recipients $mail->setFrom('
[email protected]', 'Web visitor'); $mail->addAddress('
[email protected]', 'Info'); // Add a recipient $mail->addAddress(''); // Name is optional $mail->addReplyTo('
[email protected]', 'Information'); $mail->addCC('
[email protected]'); $mail->addBCC('
[email protected]'); //Attachments $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name //Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body
in bold!'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; }