My web host has PHP's mail function disabled. I'd like to have a contact form on my site, but I've always used PHP's mail function in the past. To get around the ban my host suggested I use local SMTP instead. All day I've been trying phpmailer and Swiftmailer without much success. I know I'm using the appropriate log in information - but each time I try to send a test message I receive a 500 error. All I want is a simple contact form! I have to be missing something. Please help! SwiftMailer test code is written below:
**Index.Html**
<html>
<head>
<title>Test form to email</title>
</head>
<body>
<p>
<h1> SwiftMail Test </h1>
<form action="newnew.php" method="post">
<input type="submit" />
</form>
</p>
</body>
</html>
**newnew.php**
include_once "swift_required.php";
$subject = 'Hello!';
$from = array('mywebmail@webmail.com' =>'My Name');
$to = array(
'myemail@gmail.com' => 'My Name'
);
$html = "This is a test Email!";
$subject = "Test Subject";
$swift = Swift_Mailer::newInstance($transport);
$transport = Swift_SmtpTransport::newInstance('localhost', 465);
$transport->setUsername('mywebmail@webmail.com');
$transport->setPassword('mypassword');
$message = new Swift_Message($subject);
$message->setFrom($from);
$message->setBody($html, 'text/html');
$message->setTo($to);
if ($recipients = $swift->send($message, $failures))
{
echo 'Message successfully sent!';
} else {
echo "There was an error:
";
print_r($failures);
}