PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jul 23, 2019 1:42 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sat Mar 26, 2011 6:30 pm 
Offline
Forum Newbie

Joined: Sat Mar 26, 2011 6:25 pm
Posts: 1
Hello!

My hosting company recently started requiring SMTP, and so I have to update my contact form PHP code accordingly. I have been looking at various "newbie" topics on this board but can't seem to find one that completely answers my questions. I have the SwiftMailer code working and I am able to receive email from my contact form, but I can't figure out how to plug in the various information collecting fields. The SwiftMailer code is on top of the old PHP code I was using. Thank you for your help!!

Here is what I have:

<?php

require_once 'swift_required.php';

//Create the Transport
$transport = Swift_SmtpTransport::newInstance('mail.hummingbirdcakestationery.com', 25)
->setUsername('info@hummingbirdcakestationery.com')
->setPassword('mypassword')
;

//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

//Create a message
$message = Swift_Message::newInstance()
->setSubject(array('Hummingbird Cake Stationery Inquiry'))
->setFrom(array('info@hummingbirdcakestationery.com'))
->setTo(array('info@hummingbirdcakestationery.com'))
->setBody('PHP Swift Mailer sent with authentication')
;

/* Subject and Email Variables */

$emailSubject = 'Hummingbird Cake Stationery Inquiry';
$webMaster = 'info@hummingbirdcakestationery.com';

/* Gathering Data Variables */

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$addressField = $_POST['address'];
$cityField = $_POST['city'];
$countryField = $_POST['country'];
$commentsField = $_POST['comments'];
$newsletterField = $_POST['newsletter'];

$body = <<<EOD
<br><hr><br>
Email: $emailField <br>
Name: $nameField <br>
Address: $addressField <br>
City: $cityField <br>
Country: $countryField <br>
Comments: $commentsField <br>
Newsletter: $newsletterField <br>
EOD;

$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";

//Send the message
$result = $mailer->send($message);
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group