Help sending multiple emails pulled from a form

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
gph1
Forum Newbie
Posts: 5
Joined: Sun Oct 14, 2007 3:14 am

Help sending multiple emails pulled from a form

Post by gph1 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a form that will ask visitors to join a mailing list that will send them a puzzle once a month.  I hope.
The script pulls an email address from a form, the address is loaded into a var called $emailaddress.
I can't get an email to send if I use a variable.  It works fine if I manually put in the amail address.
every time I send it, the script tells me that it sent.  But I never get the email.
What am I doing wrong?

Thanks,

here's the critical part of the script,

Code: Select all

//Swift mailer

//Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
 
//Start Swift
$swift =& new Swift(new Swift_Connection_SMTP("mail.server.com"));
$smtp =& new Swift_Connection_SMTP("mail.server.com", 26);
$smtp->setUsername("username");
$smtp->setpassword("password");
 
$swift =& new Swift($smtp);

 
//Create the message
$message =& new Swift_Message("Joes Puzzle Page", "I hope you enjoy the puzzle.");
$recipients =& new Swift_RecipientList();
$recipients->addTo($emailaddress);

//Now check if Swift actually sends it
if ($swift->batchsend($message, $recipients, "Joe@server.com")) echo "Sent";  
else echo "Failed";

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply