The host that is running version 5 of PHP works fine, the other one does not. Here's the script.
Code: Select all
<?php
session_start();
switch($_GET['sendit']){
case 1:
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
if(empty($_POST['fullname']) || empty($_POST['youremail']) || empty($_POST['friendsemail']) || empty($_POST['message'])) {
$msg = "<font color=red>Looks like you forgot a field! Your message has not been sent.</font>";
break;
} else {
//Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
require_once "lib/Swift/Authenticator/LOGIN.php";
//Start Swift
$swift =& new Swift(new Swift_Connection_SMTP("hosting.com"));
$conn =& new Swift_Connection_SMTP("hosting.com");
$conn->setUsername("username@hosting.com");
$conn->setPassword("password");
//Create the message
$message1 =& new Swift_Message("Hey! Check out this website!");
// add your to fields to the message
$Array = $_POST["friendsemail"];
$recipients =& new Swift_RecipientList();
foreach($Array as $key => $value) {
$recipients->addTo($value);
}
$new_message = $_POST["message"] . "\n\nSee you later!" . "\n\n" .$_POST["fullname"];
stripslashes($new_message);
$part1 =& new Swift_Message_Part($new_message);
$part1->setCharset("iso-8859-2");
$message1->attach($part1);
//Now check if Swift actually sends it
if ($swift->send($message1, $recipients, new Swift_Address($_POST["youremail"], $_POST["fullname"]))) $msg = "<font color=green>Your message has been sent!</font>";
else $msg="<font color=red>Something went wrong, probably a script failure. Sorry.</font>";
}
} else {
// Insert your code for showing an error message here
$msg = "<font color=red>You provided the wrong code</font>";
}
break;
}
?>Thanks,
Paul