<?php 
require_once 'PHPMailerAutoload.php';
$server =  str_replace("www.", "", $_SERVER['HTTP_HOST']);
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'mail.'.$server;
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true;

$sql = "SELECT * FROM `smtp` WHERE email='$emails'";
$res=mysqli_query($con,$sql);
$row=mysqli_fetch_assoc($res);

    $mail->Username = $row['email'];
    $mail->Password = $row['password'];

$mail->setFrom($row['email'], 'Sells & Billing');

$mail->addAddress($_POST['email'], 'Sells & Billing');

if ($mail->addReplyTo($row['email'])) {
    $mail->Subject = 'Thanks for registration';
    //$mail->WordWrap = 50000;               // set word wrap
    $mail->Priority = 1; 
    $mail->IsHTML(true); 
    $mail->Body = '';
        if (!$mail->send()) {
            $msg = 'Sorry, something went wrong. Please try again later.';
        } else {
            $msg = 'Message sent! Thanks for contacting us.';
        }
    } else {
        $msg = 'Invalid email address, message ignored.'; 
    }
    ////////////////////////////////////////////////////////////////////////////
$server =  str_replace("www.", "", $_SERVER['HTTP_HOST']);

$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'mail.'.$server;
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true;

$sql = "SELECT * FROM `smtp` WHERE email='$emails'";
$res=mysqli_query($con,$sql);
$row=mysqli_fetch_assoc($res);

    $mail->Username = $row['email'];
    $mail->Password = $row['password'];
    
$host=str_replace("www.", "", $_SERVER['HTTP_HOST']);
$host=str_replace(".com", "", $host);
$host=str_replace(".net", "", $host);
$host=strtoupper($host);
$mail->setFrom($row['email'], $host);

$mail->addAddress($row['email'], $_POST['name']);

if ($mail->addReplyTo($row['email'])) {
    $mail->Subject = 'join now';
    //$mail->WordWrap = 50000;               // set word wrap
    $mail->Priority = 1; 
    $mail->IsHTML(true); 
    $mail->Body    = $_POST['msg'];
    $mail->AltBody = $_POST['msg'];
        if (!$mail->send()) {
            $msg = 'Sorry, something went wrong. Please try again later.';
        } else {
            $msg = 'Message sent! Thanks for contacting us.';
        }
    } else {
        $msg = 'Invalid email address, message ignored.';
    }
?>