I found this script and not sure how to use it the way I need to use it.
Where in this script would I run the sql to loop a table to get email address to people to send to ?
Here is what I am using now but some how need to implement query into this script to get emails...
Or do I still use this query and then call the function or modifie what..
Going nuts trying to figure out how to send my news letter out without issues..
I have thread for smtp mailer to go that rought but no help there either from no one yet.
$query = "SELECT email FROM letter where state='1'";
$adminEmail=getSetting("adm_mail");
$get_results = mysql_query($query);
if ($row = mysql_fetch_array($get_results)) {
do {
sendHTMLmail($adminEmail,$row[email],$title,$message);
flush();
$timeout=300;
}
while($row = mysql_fetch_array($get_results)); }
$msg="Mailing Was A Success";
}
Here is the Email Socket Script :
<?
/* ***************************************************************
* Socket_mail Function v1.4
* A simple and efficient mailing list function
* Copyright (C) 2004 GreyWyvern
*
* This program may be distributed under the terms of the GPL
* - http://www.gnu.org/licenses/gpl.txt
*
* Tested using a Linux SMTP server. I am unsure how a Windows
* SMTP server will react to this function; it may need some
* tweaking.
*
* This function accepts an array of email addresses in the form:
*
* array("Recipient's Name 1 <email@address1.com>",
* "Recipient's Name 2 <email@address2.com>",
* "Recipient's Name 3 <email@address3.com>",
* ...);
*
* See the inline comments and http://www.greywyvern.com/php.php
* for more info
*************************************************************** */
function socket_mail($toArray, $subject, $message) {
// Setup
$fromName = "Your Name";
$fromEmail = "your@address.com";
$fromMailer = "Socketmail v2.0";
$smtp = "localhost";
$smtp_port = 25;
$charset = "ISO-8859-1";
// Strip "\r" from the message (if it came from a form input)
$message = str_replace(chr(13), "", $message);
// Add a message signature (optional)
$message .= "\n\n".str_repeat("_", 60)."\n";
$message .= "$fromName <$fromEmail>\n";
$message = str_replace("\r\n.", "\r\n..", str_replace("\n", "\r\n", stripslashes($message))." \r\n");
ini_set(sendmail_from, $fromEmail);
$connect = @fsockopen ($smtp, $smtp_port, $errno, $errstr, 5);
if (!$connect) return false;
$rcv = fgets($connect, 1024);
fputs($connect, "HELO {$_SERVER['SERVER_NAME']}\r\n");
$rcv = fgets($connect, 1024);
foreach ($toArray as $to) {
$toBits = explode(" ", $to);
$toRcpt = trim($toBits[count($toBits) - 1], "<> ");
fputs($connect, "RSET\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "MAIL FROM:$fromEmail\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "RCPT TO:$toRcpt\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "DATA\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "Subject: $subject\r\n");
fputs($connect, "From: $fromName <$fromEmail>\r\n");
fputs($connect, "To: $to\r\n");
fputs($connect, "X-Sender: <$fromEmail>\r\n");
fputs($connect, "Return-Path: <$fromEmail>\r\n");
fputs($connect, "Errors-To: <$fromEmail>\r\n");
fputs($connect, "Message-Id: <".md5(uniqid(rand())).".".preg_replace("/[^a-z0-9]/i", "", $fromName)."@$smtp>\r\n");
fputs($connect, "X-Mailer: PHP - $fromMailer\r\n");
fputs($connect, "X-Priority: 3\r\n");
fputs($connect, "Date: ".date("r")."\r\n");
fputs($connect, "Content-Type: text/plain; charset=$charset\r\n");
fputs($connect, "\r\n");
fputs($connect, $message);
fputs($connect, "\r\n.\r\n");
$rcv = fgets($connect, 1024);
}
fputs ($connect, "QUIT\r\n");
$rcv = fgets ($connect, 1024);
fclose($connect);
ini_restore(sendmail_from);
return true;
}
?>