<?php

include 'db.php';

$sql = mysqli_query($link, "SELECT * FROM settings WHERE id = 1 ");
if (mysqli_num_rows($sql) > 0) {
	$data = mysqli_fetch_assoc($sql);
	$track_prefix = $data['track_prefix'];
	$track_num = $data['track_num'];
	$invoice_terms = $data['invoice_terms'];
	$allow_print = $data['allow_print'];
	$show_map = $data['show_map'];

	$email_name = $data['email_name'];
	$email_address = $data['email_address'];
	$mail_track_update = $data['mail_track_update'];
	$mail_track_save = $data['mail_track_save'];

	$sitename = $data['sitename'];
	$site_title = $data['site_title'];
	$site_url = $data['site_url'];
	$site_logo = $data['site_logo'];

	$phone = $data['phone'];
	$address = $data['address'];
}

// function sendMail($email, $subject, $body)
// {
// 	global $email_address, $email_name;
// 	$message = "$body";
// 	$headers = "MIME-Version: 1.0" . "\r\n";
// 	$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// 	// $headers .= 'From: ' . $email_name . '<' . $email_address . '>' . "\r\n";
// 	$headers .= 'From:' . $email_name . ' support@traders.freetutorz.tech' . "\r\n";
// 	return mail($email, $subject, $message, $headers);
// }


function sendMail($email, $subject, $message)
{
	global $email_address, $email_name;
	$to = "$email";

	// Always set content-type when sending HTML email
	$headers = "MIME-Version: 1.0" . "\r\n";
	$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

	// More headers
	$headers .= "from: $email_name $email_address" . "\r\n";
	$headers .= "Reply-To: $email_address \r\n";
	$headers .= "Return-Path: $email_address\r\n";
	// $headers .= "CC: $website_email\r\n";
	$headers .= "BCC: $email_address\r\n";

	return mail($to, $subject, $message, $headers, "-f $email_address");
}
