Page 1 of 1

New SwiftMail() user

Posted: Tue Mar 09, 2010 10:18 am
by GrahamG
I have been asked by my host server provider to change from PHPmailer to SwiftMailer which I have started.

I have tried a basic "test" using:

// Include this needed file
require_once 'lib/swift_required.php';

// Start the mailer
$mailer = new Swift_Mailer(new Swift_MailTransport());

// Create a message
// SYNTAX is $message = Swift_Message::newInstance('SUBJECT', 'MESSAGE', 'text/html')
// ->setFrom(array('from@email.address' => 'Graham Gillett'))
// ->setTo(array('to@email.address' => 'Test Person'));
$message = Swift_Message::newInstance('Enquiry from website', 'MESSAGE', 'text/html')
->setFrom(array('info@voxnational.co.za' => 'Graham'))
->setTo(array('$email_address' => $first_name));

// Send it
$mailer->send($message);

And this works well, and fast, BUT... when it comes to get the values from the enquiry form using say:

// get variables
$company = $_POST["Company"];
$last_name = $_POST["Last_Name"];
$first_name = $_POST["First_Name"];
$email_address = $_POST["email"];
$telephone_number = $_POST["Contact_Telephone"];
$cellphone_number = $_POST["Contact_Cellphone"];

I can't "plug-in" the variables into the test above. Anyone any idea ???