Help with SMTP Class

From: Date: Thu, 04 Jan 2001 20:56:15 +0000
Subject: Help with SMTP Class
Groups: php.general 
Request: Send a blank email to php-general+get-32709@lists.php.net to get a copy of this message
Borrowing classes from Richard Heyes and Manual Lemos, I am trying to loop through a list of email addresses in a DB and mail directly into teh SMTP port of the local server. <? <?php error_reporting(63); require('class.html.mime.mail.inc'); require('class.smtp.inc'); set_time_limit(0); function sendMail($id,$to,$from,$subj,$body) { $body .= "\n\nTo unsubscribe from this mailing list,\nplease click on the link below:\n" . "http://www.foo.com/unsubscribe.asp?MemberID=" . $id . "&Email=" . $to; $smtp = new smtp_class; $smtp->host_name = 'server.foo.com'; // Address/host of mailserver $smtp->localhost = 'foo.com'; // Address/host of this machine / HELO: $to = array('$to'); // Can be more than one address in this array. $headers = array('To: subscribers'); // A To: header is necessary, but does // not have to match the list in $to. $mail = new html_mime_mail('X-Mailer: Html Mime Mail Class'); $mail->add_html($body,$body); $mail->set_charset('iso-8859-1', TRUE); $mail->build_message(); if ($mail->smtp_send('smtp',$from, $to, $subj, $headers)) { } else { echo "could not send - $to"; } } ... ?> I get the following error: [root@server htdocs]# ./mailit.cgi <- this is a PHP CGI script (#!/usr/local/bin/php -q) <br> <b>Fatal error</b>: Call to a member function on a non-object in <b>/usr/local/apache/htdocs/class.html.mime.mail.inc</b> on line <b>307</b><br> function smtp_send($smtp_obj, $from_addr, $to_addr, $subject, $xtra_headers = ''){ global $$smtp_obj; $smtp_obj = $$smtp_obj; $headers = $this->headers; $headers[] = 'From: '.$from_addr; $headers[] = 'Subject: '.$subject; if(is_array($xtra_headers)) for(reset($xtra_headers); list(,$header) = each($xtra_headers); ) $headers[] = $header; // the following: sendmessage(string from address, array to addresses, array headers, string body) line 307: $smtp_obj->sendmessage($from_addr, $to_addr, $headers, $this->mime); } Any help with this would be greatly appreciated. Michael Geier CDMSports Systems Administration EMail: mgeier@cdmsports.com

« previous php.general (#32709) next »