Jump to content

Shade_tree_Dude

Members
  • Posts

    5
  • Joined

  • Last visited

Shade_tree_Dude's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Guess maybe I didn't make myself clear. YES it works just fine as is for sending to a single usergroup; I need to modify the code to be able to send to the users of multiple usergroups. Here is the corrected code; ignore the code in the first post as the REGEX had not been changed back to periods: // Select user group echo "<table cellspacing='0' cellpadding='0' border='0'><tr>\n"; echo "<td valign='middle' align='left' width='300'><input type='radio' name='delivery' value='grp'".$grp."> ".$locale['nl_447']."</td>\n"; echo "<td align='center'>\n"; echo "<select name='sendto' size='6' class='textbox' style='width:140px;'>"; $result = dbquery("SELECT * FROM ".DB_USER_GROUPS.""); if (dbrows($result) != 0) { while ($data = dbarray($result)) { $selected = (isset($_GET['group_id']) && $_GET['group_id'] == $data['group_id']) ? 'selected="selected"' : ''; echo "<option value='".$data['group_id']."'$selected>".$data['group_name']."</option>\n"; } } echo "</select>\n"; echo "</td>\n</tr></table><br /><br /></td>\n"; echo "</tr><tr>\n"; // End select user group // Get usergroup and email addresses $subject = stripslashes($_POST['subject']); $frommail = $settings['siteemail']; $usrtxt = stripslashes($_POST['msg']); $format = $_POST['format']; $grID = $_POST['sendto']; $result = dbquery("SELECT user_email FROM ".DB_USERS." WHERE user_newsletter='1' AND user_groups REGEXP('^\\\.{$grID}$|\\\.{$grID}\\\.|\\\.{$grID}$')"); if (dbrows($result)) { $rows = dbrows($result); while ($data = dbarray($result)) { $addies = $data['user_email'].','; $my_array = explode(",",$addies); foreach($my_array AS $dudes) { $prep = $dudes; $array[] = $prep; $list = implode(",",$array); $to_mail = $list; $list_array = explode(",",$to_mail); } } } reset($list_array); // End get usergroup
  2. Darn it! No, the REGEX uses periods. I was trying different things to make multiple select work and normalized the code before I copied and pasted into the code block. But I forgot to return the REGEX to periods, sorry; my mistake. That code uses periods and it DOES work flawlessly; unfortunately I cannot now edit the post.
  3. Where to begin? I have a very successful newsletter script for PHP-Fusion 7.02.xx CMS system. Currently it will send to single or multiple users w/attachments; also will send to a user group w/attachments. I have a need/request from a user to add multiple user group capability. Well sending to 1 user group is no problem. User groups are stored in the 'users' table like this: Say a user belongs to 3 user groups, 1 3 and 4. the 'user_groups' field for his record in the db looks like this: .1.3.4 Below is the usergroup select code and the email addies extraction code according to usergroup, that as I said currently works fine: // Select user group echo "<table cellspacing='0' cellpadding='0' border='0'><tr>\n"; echo "<td valign='middle' align='left' width='300'><input type='radio' name='delivery' value='grp'".$grp."> ".$locale['nl_447']."</td>\n"; echo "<td align='center'>\n"; echo "<select name='sendto' size='6' class='textbox' style='width:140px;'>"; $result = dbquery("SELECT * FROM ".DB_USER_GROUPS.""); if (dbrows($result) != 0) { while ($data = dbarray($result)) { $selected = (isset($_GET['group_id']) && $_GET['group_id'] == $data['group_id']) ? 'selected="selected"' : ''; echo "<option value='".$data['group_id']."'$selected>".$data['group_name']."</option>\n"; } } echo "</select>\n"; echo "</td>\n</tr></table><br /><br /></td>\n"; echo "</tr><tr>\n"; // End select user group // Get usergroup and email addresses $subject = stripslashes($_POST['subject']); $frommail = $settings['siteemail']; $usrtxt = stripslashes($_POST['msg']); $format = $_POST['format']; $grID = $_POST['sendto']; $result = dbquery("SELECT user_email FROM ".DB_USERS." WHERE user_newsletter='1' AND user_groups REGEXP('^\\\,{$grID}$|\\\,{$grID}\\\,|\\\,{$grID}$')"); if (dbrows($result)) { $rows = dbrows($result); while ($data = dbarray($result)) { $addies = $data['user_email'].','; $my_array = explode(",",$addies); foreach($my_array AS $dudes) { $prep = $dudes; $array[] = $prep; $list = implode(",",$array); $to_mail = $list; $list_array = explode(",",$to_mail); } } } reset($list_array); // End get usergroup I think I will still have to use REGEX to send to multiple usergroups but have no idea how to go about it. Any help would be appreciated.
  4. OK; I tried your suggestion and nothing is printed to the screen however; I have made significant progress. I now get the 2 or 3 attachments showing up in the received email; filenames are correct but; bytes are still zero(0)... and I get an error log entry on my cms that says cannot stat filesize. This is my cms errorlog entry: news_letter/news_letter_admin filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for For_Steven.zip Line: 172 Here is the code changes I made; I'm almost there: $content = $html_version; $headers = "From: $from"; if($_POST['fileattach'] == "yes") { $file_array = ($_POST['attach_files']); $file_list = implode(",",$file_array); $my_list = $file_list; $new_list = explode(",",$my_list); reset($new_list); } $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $content . "\n\n"; $message .= "--{$mime_boundary}\n"; // preparing attachments foreach($new_list AS $new_file) { $handle = fopen(ATTACH_FOLDER.$new_file, "rb"); $data = fread($handle, filesize($new_file)); fclose($handle); $split = chunk_split(base64_encode($data)); $message .= "Content-Type: {\"application/zip\"};\n" . " name=\"$new_file\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$new_file\"\n" . "Content-Transfer-Encoding: base64\n\n" . $split . "\n\n"; $message .= "--{$mime_boundary}\n"; } }
  5. I know there are several topics dealing with email attachments. I've studied all of them and can't seem to wrap my head around what I'm doing wrong here. The received email shows 1 Attachment as 'Part 1.2 0 bytes'... Email source shows a null for attachment 'file' and 'filename'. Also I'm trying to attach 2 files, both are zips. Any help is appreciated. Here is the most pertinent parts of my code: define("ATTACH_FOLDER", INFUSIONS . "news_letter/attach/"); include INFUSIONS."news_letter/include/attach_include.php"; switch ($delivery) { case ($delivery == 'uem'): include INCLUDES."sendmail_include.php"; // Mail send routine for single/multiple/all users $error = ""; $result = dbquery("SELECT nl_id, nl_style FROM ".DB_NEWS_LETTER." WHERE nl_id='".$_POST['nl_id']."'"); $data=dbarray($result); $style = $data['nl_style']; if ($style=="1-1col" || $style=="1-2col" || $style=="1-3col") { $template = "tmpl1.php"; } else if ($style=="2-1col" || $style=="2-2col" || $style=="2-3col") { $template = "tmpl2.php"; } else if ($style=="3-1col" || $style=="3-2col" || $style=="3-3col") { $template = "tmpl3.php"; } else if ($style=="4-1col" || $style=="4-2col" || $style=="4-3col") { $template = "tmpl4.php"; } else if ($style=="5-1col" || $style=="5-2col" || $style=="5-3col") { $template = "tmpl5.php"; } $subject = stripslashes($_POST['subject']); $from = $settings['siteemail']; $usrtxt = stripslashes($_POST['msg']); $format = $_POST['format']; $send_array = ($_POST['sendto']); $list = implode(",",$send_array); $to_email = $list; $list_array = explode(",",$to_email); reset($list_array); include INFUSIONS."news_letter/templates/$template"; require_once INFUSIONS."news_letter/include/html2text.php"; $html_version = $content; $text_version = html2text($html_version); // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $content = $html_version; $headers = "From: $from"; if($_POST['fileattach'] == "yes") { $file_array = ATTACH_FOLDER.($_POST['attach_files']); } $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $content . "\n\n"; $message .= "--{$mime_boundary}\n"; // preparing attachments for($x=0;$x<count($file_array);$x++){ $file = fopen($file_array[$x],"rb"); $data = fread($file,filesize($file_array[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$file[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$file[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; $message .= "--{$mime_boundary}\n"; } } foreach($list_array AS $to_mail) {
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.