Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isset($_POST['send'])){
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- $dataemail = $_POST['email'];
- $datasubject = $_POST['subject'];
- $datadeskripsi = $_POST['deskripsi'];
- $query = mysqli_query($link,"INSERT INTO mailer (email,subject,deskripsi)VALUES('$dataemail','$datasubject','$datadeskripsi')");
- if($query){
- echo "sukses";
- }
- else {
- echo "gagal";
- }
- $emailTo = $_POST['email'];
- $subject = $_POST['subject'];
- $deskripsi = $_POST['deskripsi'];
- //Server settings
- $mail->SMTPDebug = 0; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = SMTPUSER; // SMTP username
- $mail->Password = SMTPPASS; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- //Recipients
- $mail->setFrom('adirahman.id@gmail.com', 'adi rahman');
- $mail->addAddress($emailTo); // Add a recipient
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = $subject;
- $mail->Body = $deskripsi;
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement