Page 1 of 1

Using variables loaded from flash in swift mailer scripts

Posted: Thu Sep 10, 2009 3:08 pm
by aszurley
Hello
I'm having trouble with $_POST and using the variables my uisers generate in a flash application. Using php outside of Swift Mailer I was able to successfully make this happen. Is there a syntax that I'm not getting here.

I'm using this for the setTo() header: $_POST["email2"];
&
I'm using this in the html setbody():
'Your Contact name is: -------------- <b>{$_POST["contact2"]}</b><br>'.
'Your Email is: --------------------- <b>{$_POST["email2"]}</b><br>'.
'Your Cell Number is: --------------- <b>{$_POST["cell2"]}</b><br>'.
'Your Zip Code is: ------------------ <b>{$_POST["zip2"]}</b><br>'.

Thanks for any help or direction.
a

Re: Using variables loaded from flash in swift mailer scripts

Posted: Thu Sep 10, 2009 8:08 pm
by John Cartwright
When evaluating arrays inside curly brackets, you need to omit the quotes around the keys, i.e.,

Code: Select all

'Your Contact name is: -------------- <b>{$_POST[contact2]}</b><br>'.
'Your Email is: --------------------- <b>{$_POST[email2]}</b><br>'.
'Your Cell Number is: --------------- <b>{$_POST[cell2]}</b><br>'.
'Your Zip Code is: ------------------ <b>{$_POST[zip2]}</b><br>'.

Re: Using variables loaded from flash in swift mailer scripts

Posted: Fri Sep 11, 2009 11:24 am
by aszurley
John
Thanks for the reply and sorry for the breach in protocol. I'm having issues with the "->setTo()" line in my code. Is it not in proper format to get $_POST from flash? I have tried it several different ways, but with no success:

Code: Select all

<?php
 
session_start();
$ses_id = session_id(); 
$prodID = $ses_id . ".jpg";
 
require_once 'lib/swift_required.php';
 
$smtp = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($smtp);
 
$message = Swift_Message::newInstance('Maverik Lacrosse Customizer Retailer Product details');
$message
->setTo = $_POST['email2'];
->setFrom(array('custom@company.com' => 'Customer Name'))
->setBcc(array('me_@blah.com' => 'MyName'))
 
->setBody(
'<html>'.
'<table width="800" cellspacing="0" cellpadding="0">'.
'<body>'.
'<tr>'.
'<td style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 150%; color: black">
<meta http-equiv="Content-Type" content="text/html;charset= utf-8;">'.
'<b>Your Product Details</b><br>'.
'--------------------------------------------------------------------------------------------------------<br>'.
'Your Contact name is: -------------- <b>{$_POST[contact2]}</b><br>'.
'Your Email is: --------------------- <b>{$_POST[email2]}</b><br>'.
'Your Cell Number is: --------------- <b>{$_POST[cell2]}</b><br>'.
'Your Zip Code is: ------------------ <b>{$_POST[zip2]}</b><br>'.
'--------------------------------------------------------------------------------------------------------<br>'.
'<br>'.
'Thank you for visiting the customers site.<br>'.
'One of our sales representatives will contact you shortly to confirm your order.<br>'.
'<br>'.
'<b>Please remember that:</b><br>'.
'<b>1)</b> Our delivery time is based on availability<br>'.
'<b>2)</b> The product colors cannot match exactly to the screen values<br>'.
'<b>3)</b> Your logo art needs to be camera ready or in digital form.<br>'.
'<br>'.
'<b>Here is the product you designed:</b><br>'.
'--------------------------------------------------------------------------------------------------------<br>'.
'<br>'.
'<img src="' . $message->embed(Swift_Image::fromPath($prodID)) . '" />'.
'</p>'.
'</td>'.
'</tr>'.
'</body>'.
'</table>'.
'</html>', 'text/html')
 
->addPart(
'--------------------------------------------------------------------------------------------------------
Your Contact name is: -------------- {$_POST["contact2"]}
Your Email is: --------------------- {$_POST["email2"]}
Your Cell Number is: --------------- {$_POST["cell2"]}
Your Zip Code is: ------------------ {$_POST["zip2"]}
--------------------------------------------------------------------------------------------------------
            
Thank you for visiting the Customizer site. One of our sales representatives will 
contact you shortly to confirm your order.
 
Please remember that:
1) Our delivery time is based on availability
2) The product colors cannot match exactly to the screen values
3) Your logo art needs to be camera ready or in digital form.
--------------------------------------------------------------------------------------------------------', 'text/plain')
;
//Send the message
$mailer->send($message);
?>