Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\Exception;
- use PHPMailer\PHPMailer\PHPMailer;
- require '/vendor/autoload.php';
- $mail = new PHPMailer(true);
- $name = test_input($_POST["name"]);
- $email = test_input($_POST["email"]);
- $phone = test_input($_POST["phone"]);
- $subject = test_input($_POST["subject"]);
- $message = test_input($_POST["message"]);
- //add your email details here!
- $mySmtpHost = '';
- $myEmail = '';
- $myemailPassword = '';
- $myPhone = '';
- $Body = "<html>
- <body>
- <h2>You have a message from www.fatmaardabicaz.av.tr website user</h2>
- <hr>
- <p>Isim:<br>`.$name.`</p>
- <p>E-mail:<br>`.$myEmail.`</p>
- <p>Telefon:<br>`.$myPhone.`</p>
- <p>Mesaj:<br>`.$message.`</p>
- </body>
- </html>";
- try {
- $mail->isSMTP();
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->Host = $mySmtpHost;
- $mail->SMTPAuth = true;
- $mail->Username = $myEmail;
- $mail->Password = $myemailPassword;
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- // $headers = "From: " . $name . " <" . $email . ">\r\n";
- // $headers = "MIME-Version: 1.0\r\n";
- // $headers = "Content-type: text/html; charset-utf-8";
- // $name = $_POST['name'];
- // $email = $_POST['email'];
- // $phone = $_POST['phone'];
- // $subject = $_POST['subject'];
- // $message = $_POST['message'];
- // $to = "mymailaddress.com";
- //sent from (your email,your subject)
- $mail->setFrom($myEmail, $subject);
- //who you are sending the email to
- $mail->addAddress($email, $name); // Name is optional
- $mail->addReplyTo($myEmail, 'Information');
- // Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- // $mail->Body = '<html>
- // <body>
- // <h2>You have a message from www.fatmaardabicaz.av.tr website user</h2>
- // <hr>
- // <p>Isim:<br>`.$name.`</p>
- // <p>E-mail:<br>`.$email.`</p>
- // <p>Telefon:<br>`.$phone.`</p>
- // <p>Mesaj:<br>`.$message.`</p>
- // </body>
- // </html>';
- // $txt = " You have a message from: " . $name . ".\n\n" . $message;
- // Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = $message;
- $mail->setLanguage('tr', 'vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php');
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
- }
- function test_input($data)
- {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement