Im trying to use swift mailer to email to an email address that gets pulled out of my database. but Im not having any luck. heres what I have for the code. The error I get I know why i get it I just dont know how to get around it. in the line
$swift->send($message, $to, "FindMeAFare.com@findmeafare.com"); where I have $to swift doesnt recoginize it as an email address it reads it in as an incorrect string. ive tried changing $to -> "".to$ thinking I could force the variable into the quotes but nothing :S
Just incase here is the error I get, Notice: The recipients parameter must either be a valid string email address, an instance of Swift_RecipientList or an instance of Swift_Address. in /home/content/f/m/a/fmafadmin/html/swift/Swift.php on line 392
Any help would be fantastic
PS: IF I test it with a given email it doesnt sent the .rows['name']; variable either :cry
Code: Select all
<?php
$con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$id = 20;
$result = mysql_query("SELECT * FROM main2 WHERE main2.id = $id");
$row = mysql_fetch_array($result);
echo "Name: ".$row['name']; // is just here to confirm the proper name and email
echo " Age: ".$row['email'];
require_once "swift/Swift.php";
require_once "swift/Swift/Connection/NativeMail.php"; //There are various connections to use
$swift =& new Swift(new Swift_Connection_NativeMail());
$message =& new Swift_Message("Fare Request From: ".$rows['name']);
$to = $rows['email'];
$swift->send($message, $to, "FindMeAFare.com@findmeafare.com");
?>