Saturday, 17 August 2013

Swiftmailer on Webserver - Doesn't work like locahost

Swiftmailer on Webserver - Doesn't work like locahost

I'm using Swiftmailer to send mail form my contact form, which works on
localhost as I've edited the php.ini file to use "smtp.gmail.com" on
port:587.
<?php
require_once 'Swift/lib/swift_required.php';
// Create the mail transport configuration
$transport = Swift_MailTransport::newInstance();
// Create the message
$message = Swift_Message::newInstance();
$message->setTo(array(
"name@name.com" => "Name"
));
$message->setSubject("This email is sent using Swift Mailer");
$message->setBody("You're our best client ever.");
$message->setFrom("From@from.com", "Example from");
// Send the email
$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($message);
?>
However, if I go to use to code on my webserver, it doesn't send. I'm
wondering if I have to configure something in the cPanel, or the php file
in order to send mail? mail() doesn't work on here either.

No comments:

Post a Comment