Location: PHPKode > scripts > Contact Grabber And Invite > contact-grabber-and-invite/invite/invite.php
<?php

require_once "/home/yoursite/public_html/addons/swiftmailer/lib/Swift.php";
require_once "/home/yoursite/public_html/addons/swiftmailer/lib/Swift/Connection/NativeMail.php"; //There are various connections to use
include("/home/yoursite/public_html/includes/connect.inc.php"); 

$swift =& new Swift(new Swift_Connection_NativeMail());
 Swift_CacheFactory::setClassName("Swift_Cache_Disk");
 
//Then you set up the disk cache to write to a writable folder...
Swift_Cache_Disk::setSavePath("/home/yoursite/public_html/addons/swiftmailer/tests/tmp");
 
$message =& new Swift_Message("Invitation from Yoursite!");


$message->attach(new Swift_Message_Part("Hello,

This is an invitation to visit http://yoursite.com

Powered by kkonline.org"));

//Use the Swift_File class
$message->attach(new Swift_Message_Attachment(
  new Swift_File("/home/yoursite/public_html/path/to/attachment/attach.pdf"), "attach.pdf", "application/pdf"));

$sql = "SELECT * FROM invites WHERE `invitation` = 0 AND AND trusted = 1 LIMIT 0,35";

$result = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_array($result)){

$email=$row['email'];
$id=$row['id'];
$recipients =& new Swift_RecipientList();
$recipients->addTo($email);
echo $id . ' ' . $email . ' ... sent<br>';
$swift->batchSend($message, $recipients, "hide@address.com");

mysql_query("UPDATE invitation SET status = 1 WHERE id = ".$id);
}

echo "Invitation Sent...";
$swift->disconnect();
?>
Return current item: Contact Grabber And Invite