scamout Posted February 6, 2010 Share Posted February 6, 2010 I'm not a PHP guy - someone else wrote my code. I have a php script that steps through a mySQL database to pull email addresses and reads a text file which it sends as an email. It work fine. Here is the relevant code: //READ THE FILE INTO MEMORY AND FORMAT THE EMAIL TEXT $filename = "/home/scamout/public_html/test.txt"; $fp = fopen($filename, "r"); // $EMailText = "Hello,"; $EMailText .= "\n\n"; $EMailText .= (fread($fp, 60000)); fclose($fp); //END FILE READ // PERFORM SQL QUERY TO GET ALL ACTIVE MEMBERS $query = "SELECT MemberEmail FROM members where DateAdded < 2004-06-01 21:00:00 and Status > 3"; $result = mysql_query($query) or die( mysql_error($DB_link) ); while ( $line = mysql_fetch_array($result) ) { $emailaddr = $line["MemberEmail"]; $FromId = "Merchant911 Admin <[email protected]>"; $EMailSubject = "[MERCHANT 911] Important Mail from Merchant911"; $headers = array ('From' => $FromId,'To' => $emailaddr,'Subject' => $EMailSubject) ; $sendit = Mail::factory('smtp',array ('host' => "mail.merchant911.org",'auth' => true,'username' => "myusername",'password' => "mypasswords")); $mail = $sendit->send($emailaddr, $headers, $EMailText); Now I need to send out html email. After much Google searching and lots of trial and error, I amended the $headers portion to this: $headers = array ('From' => $FromId,'To' => $emailaddr,'Subject' => $EMailSubject) ; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; I'm not getting errors in that portion of the code (finally) but now I'm getting: Warning: Invalid argument supplied for foreach() in /usr/local/lib/php/Mail.php on line 123 Warning: Invalid argument supplied for foreach() in /usr/local/lib/php/Mail.php on line 151 The all member mailing completed. On a shared server, I don't have access to Mail.php so I can't go further. Can someone help? Link to comment https://forums.phpfreaks.com/topic/191113-sending-html-formated-email-with-php/ Share on other sites More sharing options...
premiso Posted February 6, 2010 Share Posted February 6, 2010 Your server is using PEAR, which is good. http://www.phpmaniac.net/wiki/index.php/Pear_Mail#Sending_your_first_email See that tutorial for instructions on sending an html email with PEAR. Link to comment https://forums.phpfreaks.com/topic/191113-sending-html-formated-email-with-php/#findComment-1007730 Share on other sites More sharing options...
scamout Posted February 6, 2010 Author Share Posted February 6, 2010 I'm sorry, Premiso, Like I said, I'm not a programmer. That stuff means almost nadda to me. Tried a couple things from there and broke everything. Link to comment https://forums.phpfreaks.com/topic/191113-sending-html-formated-email-with-php/#findComment-1007747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.