• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[ZNOTE ACC] - Contact page | working sending mails

Szmycu

Tibiaservers.net
Joined
Sep 2, 2008
Messages
63
Reaction score
5
Location
Poland
Firstly You have to do:

Please consider using a released stable version of PHPMailer or you may run into issues.
Download PHPMailer: Releases · PHPMailer/PHPMailer (https://github.com/PHPMailer/PHPMailer/releases)
Extract to Znote AAC directory (where this config.php file is located)
Rename the folder to "PHPMailer". Then configure this with your SMTP mail settings from your email provider.
Capture_318.jpg

In the config.php file provide info in $config['mailserver']

Next thing we have to put this code in contact.php

PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1><b>Contact</b></h1>
<h4>Write your message below and fill all fields</h4>
<br>

<form class="contact-form" action="" method="post">
        <ul>
            <li>
                Your character Name:<br>
                <input placeholder="Character name" name="visitor_name" id="name" class="form-control medium_input" type="text" name="username" required>
            </li>
            <li>
                Email:<br>
                <input placeholder="Your email: [email protected]" id="mail" class="form-control medium_input" type="text" name="visitor_email"  required>
            </li>
            <li>
                Message:<br>
                <textarea id="message" class="form-control message" name="visitor_message" placeholder="Your message..." required></textarea>
            </li>
            <li>
                <input class="btn-lg btn-primary" type="submit" value="Send Message">
            </li>
            
        </ul>


</form>


<?php



if (isset($_GET['success'])) {
    echo "<h3 style='color:green;'>Thanks for contacting. You will get reply in 1-5 hours,</h3>";
}



if($_POST){

    // first balues empty
    $visitor_name = '';
    $visitor_email = '';
    $message = '';


    if (isset($_POST['visitor_name'])) {
        $visitor_name = filter_var($_POST['visitor_name'], FILTER_SANITIZE_STRING);
    }

    if (isset($_POST['visitor_email'])) {
        $visitor_email = str_replace(array("\r", "\n", "%0a", "%0d"), '', $_POST['visitor_email'] );
        $visitor_email = filter_var($_POST['visitor_email'], FILTER_VALIDATE_EMAIL);
    }

    if (isset($_POST['visitor_message'])) {
        $visitor_message = htmlspecialchars($_POST['visitor_message']);
    }



    $mailer = new Mail($config['mailserver']);

    $title = "Email from GemOTS";

    $body = "<h1>Email from GemOTS</h1>";
    $body .= "<p>User mail - {$visitor_email} and user char name - {$visitor_name}</p>";
    $body .= "<p>Message {$visitor_message}.</p>";


    $user_name = ($config['ServerEngine'] !== 'OTHIRE') ? $user_data['name'] : $user_data['id'];
    //echo "<h1>" . $title . "<h1>" . $body;
    $mailer->sendMail('YOUR_MAIL', $title, $body, $user_name);


    header("Location: " . $_SERVER["REQUEST_URI"] . "?success");
    exit;
            


}


?>



<?php include 'layout/overall/footer.php'; ?>

only thing u have to edit is $mailer->sendMail('YOUR_MAIL', $title, $body, $user_name);
Change YOUR_MAIL to your mail(where msg would be send)

Now its sending mails.​

 
Top