Re: Help with SMTP Class

From: Date: Thu, 04 Jan 2001 21:07:33 +0000
Subject: Re: Help with SMTP Class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32711@lists.php.net to get a copy of this message
try echo gettype( $smtp_obj ) somewhere along the line. it must be object. At 21:56 4.1. 2001, Michael Geier wrote the following: -------------------------------------------------------------- >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 > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net ------end of quote------ ____________________________________________________________ Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. cynic@mail.cz

« previous php.general (#32711) next »