I'm trying to figure out my issue, I have a shared hosting provide that had the PHP mail function disable for security reasons.
I need to send some forms data using PHP, I only know how to send form data using the PHP mail function.
I tried using phpmailer, got ir from GitHub, but it didn't worked.
My question is very simple, is there a workaround to send form data without the PHP mail function to bypass the disabled phpmail and nobody=on tweak on my shared web hosting?
<?php
function send_mail($email, $recipient_name, $message='')
{
require("phpmailer/class.phpmailer.php");
require("phpmailer/class.smtp.php");
$mail = new PHPMailer();
$mail->CharSet="utf-8";
$mail->IsSMTP();
$mail->Host = 'localhost';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "user@mysite.com";
$mail->Password = "password";
$mail->setFrom($email, $recipient_name);
$mail->AddAddress($email, $recipient_name);
$mail->WordWrap = 50;
$mail->IsHTML(false);
$mail->Subject = "Contact form";
$mail->Body = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
}
//vars
$subject = "Contac form";
$from = $_POST['email'];
//data
$msg = "NAME: " .$_POST['name'] ."<br><br>
";
$msg .= "EMAIL: " .$_POST['email'] ."<br><br>
";
$msg .= "WEBSITE: " .$_POST['website'] ."<br><br>
";
$msg .= "MESSAGE: " .$_POST['message'] ."<br>
";
//Headers
$headers = "MIME-Version: 1.0
";
$headers .= "Content-type: text/html; charset=UTF-8
";
$mail="support@mysite.com";
//send mail
//mail($mail, $subject, $msg, $headers, "-f $from");
send_mail($from, $_POST['name'], $msg);
?>