PHP - Phpmailer And Bcc Groups Of Recipients...
Hello,
I am sending an email via phpmailer to a large group of recipients.
I bcc'd the entire group which of course failed after the max limit was reached so I thought what about sending in chunks....
Im just trying to figure out how to loop through the groups of bcc's
basically Im thinking something like this...
$mail = new PHPMailer(true); $mail->IsSMTP(); //setup from, replyto etc here... //email query here to get emails in array $bccz.. //chunk results $newArray = array_chunk($bccz, 50, false); // Now process array_chunk() $i = 0; foreach ($newArray as $inner_array) { $i++; while (list($key, $value) = each($inner_array)) { addBCC($value['email']); }$subject = '=?UTF-8?B?'.base64_encode($cobig).'?='; $mail->Subject = $subject; $mail->IsHTML(true); $mail->Body = $ermail; $mail->Send(); } $mail->clearBcc(); }Just wondering if someone can tell me if this basic logic is right? Similar TutorialsI got a form which people can use to send a request for information to one or more recipients, depending on which recipients have been selected in the form. At the moment the HTML checkboxes all have a different name attribute and e-mails are sent using an if statement: <input type="checkbox" name="mr-a" value="A" /> A<br /> <input type="checkbox" name="mr-b" value="B" /> B<br /> <input type="checkbox" name="mr-c" value="C" /> C<br /> if (isset($_POST['mr-a'])) { // Send e-mail to A } if (isset($_POST['mr-b'])) { // Send e-mail to B } if (isset($_POST['mr-c'])) { // Send e-mail to C } I'm sure there's a much better way of doing this, and I think I should start by creating an array of checkboxes. But I can't figure out how to then use a loop to send the e-mails. Here's the code I got so far. I'm hoping that all I need is a loop where is says 'Send e-mails using a foreach loop?': <?php // Minimal validation: if (isset($_POST['submit'])) { $errors = array(); if (!$_POST['name'] ) { $errors[] = 'Error: no name entered'; } else { $name = $_POST['name']; } if (!$_POST['email'] ) { $errors[] = 'Error: no e-mail address entered'; } else { $email = $_POST['email']; } if (!count($errors)) { // Send e-mails using a foreach loop? } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Lorem Ipsum</title> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body id="index" class="home"> <h1>Lorem Ipsum</h1> <p>Confirmation message.</p> </body> </html> <?php // Get out! exit(0); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Lorem Ipsum</title> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body id="index" class="home"> <h1>Lorem Ipsum</h1> <p>Contact A, B and/or C.</p> <?php if (isset($errors)) { foreach ($errors as $error) { echo("<p class=\"red\">$error<p>"); } } ?> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <fieldset> <legend>Who do you want to contact</legend> <input type="checkbox" name="mr[]" value="A" /> A<br /> <input type="checkbox" name="mr[]" value="B" /> B<br /> <input type="checkbox" name="mr[]" value="C" /> C<br /> </fieldset> <br /> <fieldset> <legend>Your Details</legend> <label for="name">Name</label><input type="text" name="name" value="<?php if (isset($_POST['name'])) {echo $_POST['name'];}?>"><br /> <label for="email">Email</label><input type="email" name="email" value="<?php if (isset($_POST['email'])) {echo $_POST['email'];}?>"><br /> <input type="submit" name="submit" value="Next" /> </fieldset> </form> </body> </html> Hello I am after some guidance on the following scenario: I have a news page that pulls from a database and would like to seperate it out by year, see below 2010 Bulletin 2 - 23/11/2010 - Some news here..... Bulletin 1 - 21/11/2010 - Some news here..... 2009 Bulletin 2 - 23/11/2009 - Some news here..... Bulletin 1 - 21/11/2009 - Some news here..... How can i do this automatically and seperate them out by year like above I'm using Active Directory and PHP with LDAP. I have been trying to create a script that will list all the members of each group in a OU. When I run this script in an OU with Users, it will return an array with all the available attributes of each User. However when I use it with a group, it doesn't return any attributes of the group. Code: [Select] <?php $ig_ldaphost="LDAP://domain/"; //filtered for security $ig_ldapou="OU=Drive Security,OU=Groups,DC=this,DC=and,dc=that"; //filtered for security $ig_ldapconn=ldap_connect($ig_ldaphost) or die("Could not connect to {$ig_ldaphost}"); $ig_ldapopt=ldap_set_option($ig_ldapconn,LDAP_OPT_PROTOCOL_VERSION,3) or die("Could not set options: {$ig_ldapopt}"); $ig_ldapbind=ldap_bind($ig_ldapconn) or die("Could not bind: {$ig_ldapbind}"); $ig_ldapsearch=ldap_search($ig_ldapconn,$ig_ldapou,"objectClass=*"); for ($ig_ldapentry=ldap_first_entry($ig_ldapconn,$ig_ldapsearch);$ig_ldapentry!=FALSE;$ig_ldapentry=ldap_next_entry($ig_ldapconn,$ig_ldapentry)) { $ig_ldapvalues=ldap_get_attributes($ig_ldapconn,$ig_ldapentry); $ig_ldapdn=ldap_explode_dn(ldap_get_dn($ig_ldapconn,$ig_ldapentry),1); echo "/".$ig_ldapdn[1]."/".$ig_ldapdn[0]."<br />"; var_dump($ig_ldapvalues); echo "<br /><br />"; } ldap_close($ig_ldapconn); ?> Can anyone help with this? Dear all, I am new in this forum. This is my code $query = " SELECT webdb.id, webdb.writer, writer.picLoc, webdb.title FROM webdb, writer WHERE webdb.writer=writer.name and category = 'Researchworks' and language = 'Farsi' ORDER BY writer DESC"; $resultaat = mysql_query($query, $LinkID); $column_count = mysql_num_fields($resultaat) or die (mysql_error()."<br>Couldn't execute query: $SQLquery"); $counter=1; echo "<table border=\"0\" width=\"700\" border color=white><tr>"; while ($row = mysql_fetch_row($resultaat)) { if ($author !== $row[1]) { $author = $row[1]; echo "<td align=right width=220 valign=top style=\"margin: 5px; float: right border-bottom-color:#000; border-left-color:#000;\">"; echo "<img width=\"50\" height=\"80\" src=\"admin/writers/$row[2]\" border =\"0\"><br>".$row[1]."<br>"; echo "<a href=\"poems.php?writer=$row[1]\">".$row[3]."</a><br>"; echo "</td>"; if($counter%3==0) { echo"</tr><tr>"; } $counter++; } } echo"</tr></table>"; i have authors with different articles on a certain topic. What i want is, displaying the name of the author only once and all his titles under his name. I also want a dynamic table where i display three authors in each row and soon as there a fourth author a new row must start. My problem now is is the title is also being filtered and i can only display one title. Thanks in advance I have a group of 4 radio buttons. my mysql database knows which one the user selected previously when they stored some information. I now wish to display the same buttons but have radio button checked that the user chose before. I know this can be done but having one of those mind melt moments where I cannot think of the solution so I have 4 buttons that look like this Code: [Select] <input type="radio" name="clarity" id="clarity" value="Opaque"> Opaque<br> <input type="radio" name="clarity" id="clarity" value="Deep"> Deep<br> <input type="radio" name="clarity" id="clarity" value="Mid"> Mid<br> <input type="radio" name="clarity" id="clarity" value="Pale"> Pale<br></td> I just need to attached a checked field to the correct item Hi, I know very little about binding PHP to AD. At the minute it is setup to Authenticate against AD (Via IIS), then from the that I have the following: Declare's the Logon_Name variable, so that it can be used to 'print' buttons, and links i.e. if ($logon_name==("Administrator")); {echo admin link here'}; $logon_name = basename($_SERVER['AUTH_USER']); What I would ideally like to do is be able to find the group the user is a member of, this way we can create custom AD groups like intra_admin and then if they are a member they will be able to see certain links to pages etc. Any ideas, I hope this makes sence I have started a project using laravel. I am in the process of builing User groups and permissions in the admin dashboard.
I have uploaded a snapshot of my views to which i want to restrict access. i want to structure it to be completely dynamic
views.PNG 9.41KB
0 downloads
Hey all, I'm wondering the best way to use foreach to break a list of records into groups. For example, the problem with this: Code: [Select] foreach($vanity_url as $v){ if($v->approved){ echo "Approved vanity urls:"; echo $v->url; } else { echo "Unapproved vanity urls:"; echo $v->url; } } is it will return this: Code: [Select] Approved vanity urls: michellefrancis Unapproved vanity urls: johnmerlino Unapproved vanity urls: ericmayers when I want it to return this: Code: [Select] Approved vanity urls: michellefrancis Unapproved vanity urls: johnmerlino ericmayers thanks for response Hello Guys This is the first time i ask a question at php freaks. Hope i could find the answer. I want to create something similar to the image now the problem is that i want to get groups and their users in the same array. Notice something like Array => Group1 [1] => user1 [2] => user2 [3] => Group2 and so on. How could i do that. Thanks in advance. What I am looking for is a small script that works in the way that http://www.groupsort.com/ works. This is for a sports organization. Loads of registrations entered into a MySQL database which need to be automatically sorted into classes that have already been created with an age range specified (Class: S1, From: 1997, To: 1999, Sex: Mixed) Whereas there are some classes with the same set of rules, I have no idea of how I should divide the correct amount of children into correct classes. Can you help? Hi
I have a two dimensional array and would like to output the results in groups depending upon one of the fields in the array. While i have managed this and have figured out how to create a header for each group, i would now like to create a footer (end of group) line where i could create a subtotal or similar.
my working code with the header is below but how do i add the footer?
$group = null; for($i=0;$i<count($rowKitCharges);$i++){ if($rowKitCharges[$i]['SubCategory'] != $group) { //echo the group header echo "<br><b>" . $rowKitCharges[$i]['SubCategory'] . "</b><br>"; $group = $rowKitCharges[$i]['SubCategory']; } echo $rowKitCharges[$i]['HireID'] . " " . $rowKitCharges[$i]['SubCategory']; echo "<br>"; }Thanks Jon I have a form on a PHP page which has 11 groups of radio buttons. Is there way to use PHP instead of client-side JavaScript to submit the form values only when one radio button has been selected from each of the 11 groups? Also, is it possible to get the form elements in a PHP page with JavaScript? Why does this JavaScript: Code: [Select] myForm.elements.lengthstop working in a PHP page? I thought it wouldn't affect client-side JS since PHP is server-side code. Thank you! Hi, I need some help getting my head around arrays. I have a basket of fruit: $basket=("Apple","$Orange","$Banana","$Banana","$Peach","$Apple","$Banana","$Orange","$Apple"); I want to distribute and share this basket of fruit into bowls, such that each bowl contains the following: $bowl=("$Apple",$Orange,"$Banana","$Banana") ie. One Apple, One Orange & Two Bananas. I can't seem to figure out how to do it. Thanks in advance. hey guys im using phpmailer (https://github.com/PHPMailer/PHPMailer) to send mail from my server to users using SMTP...the problem im getting is that when i send a mail it goes stright into the junk mail...how can i please stop this please?
$mail = new \Mail\Mail; $mail->isSMTP(); $mail->Debugoutput = 'html'; $mail->Host = "****"; $mail->Port = 25; $mail->SMTPAuth = true; $mail->Username = "****"; $mail->Password = "***"; $mail->setFrom('***', '****'); $mail->addAddress('email@hotmail.co.uk', 'user'); $mail->Subject = 'BiSi - Welcome'; $mail->msgHTML('<a href="test">hello</a>'); $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; if (!$mail->send()) { echo "Mailer Error: "; } else { echo "Message sent!"; } Will someone, who doesn't mind helping an old man understand some things, explain how to use PHPMailer?
You see, I downloaded a registration form that sends a verification e-mail. I'm testing all of this on my local machine (Linux). The mail, of course, fails to be delivered. So I surf around and see where phpmailer can help me with this. So I downloaded phpmailer-master. But I have absoultely no idea where to put what so I'll have e-mail capability from localhost.
If you can tell me what goes where, I promise to name my next child after ya I just need some guidance on this one. It has me totally confused!
Landslyde
PS: Happy 2015 to all!
Edited by Landslyde, 30 December 2014 - 11:17 PM. Hi. I'm using PHP mailer. But I can't get it to send the Email: Class: Code: [Select] public function send_notification($sendTo, $name, $from_name, $from_email, $body_content, $subject){ $message =<<<EMAILBODY {$body_content} EMAILBODY; $message = wordwrap($message, 70); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "localhost"; $mail->Port = 25; $mail->SMTPAuth = false; $mail->isHTML(TRUE); $mail->FromName = $from_name; $mail->From = $from_email; $mail->AddAddress($sendTo, $name); $mail->Subject = $subject; $mail->Body = $message; $result = $mail->Send(); return $result; } PHP Code: [Select] $body_content = ' Dear BusinessMobile.com <br /><br /> A website user has filled in the form on the website. See the details below. <br /><br /> Company: '.$company.'<br /> Name: '.$name.'<br /> Email: '.$email.'<br /> Tele: '.$telephone.'<br /> Message: '.$message.'<br /><br /> Interest: '.$Fpage.'<br /> Reference: '.$ref.'<br /><br />'; $subject = 'BusinessMobile.com - Contact Request'; Form_signup::send_notification('spires1@mail.com', 'BM', 'BM', 'spires1@mail.com', $body_content, $subject); Any ideas where i'm going wrong ? Thanks I am setting up PHPMailer to send pdf's from my server and I have just come into the following error: Quote Deprecated: Function set_magic_quotes_runtime() is deprecated in /var/www/PHPMailer_v5.1/class.phpmailer.php on line 1471 Deprecated: Function set_magic_quotes_runtime() is deprecated in /var/www/PHPMailer_v5.1/class.phpmailer.php on line 1475 The code in question is this (I've pointed out the lines mentioned above): Code: (php) [Select] <?php /** * Encodes attachment in requested format. * Returns an empty string on failure. * @param string $path The full path to the file * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' * @see EncodeFile() * @access private * @return string */ private function EncodeFile($path, $encoding = 'base64') { try { if (!is_readable($path)) { throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); } if (function_exists('get_magic_quotes')) { function get_magic_quotes() { return false; } } if (PHP_VERSION < 6) { $magic_quotes = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); //<-- Here } $file_buffer = file_get_contents($path); $file_buffer = $this->EncodeString($file_buffer, $encoding); if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } //<-- Here return $file_buffer; } catch (Exception $e) { $this->SetError($e->getMessage()); return ''; } } So my question is, how can I get rid of this error? How should I best edit this function to no longer use the deprecated set_magic_quotes_runtime()? Any help is appreciated, Joe I have been away from a coding project for over 2 years. Trying to get things online, and not cause further delays. My site uses the PHP Mailer class to send out emails to users for things like password resets. How important is it that I have the latest version of this class - assuming it is even still around now? Thanks. I am trying to get phpmailer working but not having much luck with it. I am not receiving the email Below is the code I have <?php //index.php $error = ''; $quantity1 = ''; $totalprice1 = ''; $subtotal = ''; $postage = ''; $grandtotal = ''; $name = ''; $addressline1 = ''; $postcode = ''; $email = ''; function clean_text($string) { $string = trim($string); $string = stripslashes($string); $string = htmlspecialchars($string); return $string; } if(isset($_POST["submit"])) { if(empty($_POST["quantity1"])) { $error .= '<p><label class="text-danger">Please enter the quantity required</label></p>'; } if(empty($_POST["totalprice1"])) { $error .= '<p><label class="text-danger">Please enter the total price required</label></p>'; } if(empty($_POST["subtotal"])) { $error .= '<p><label class="text-danger">Please enter the subtotal</label></p>'; } if(empty($_POST["postage"])) { $error .= '<p><label class="text-danger">Please enter the postage</label></p>'; } if(empty($_POST["grandtotal"])) { $error .= '<p><label class="text-danger">Please enter the grand total</label></p>'; } if(empty($_POST["name"])) { $error .= '<p><label class="text-danger">Please Enter your name</label></p>'; } else { $name = clean_text($_POST["name"]); if(!preg_match("/^[a-zA-Z ]*$/",$name)) { $error .= '<p><label class="text-danger">Only letters and white space allowed</label></p>'; } } if(empty($_POST["addressline1"])) { $error .= '<p><label class="text-danger">Please enter your address line 1</label></p>'; } if(empty($_POST["postcode"])) { $error .= '<p><label class="text-danger">Please enter your postcode</label></p>'; } if(empty($_POST["email"])) { $error .= '<p><label class="text-danger">Please Enter your Email</label></p>'; } else { $email = clean_text($_POST["email"]); if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error .= '<p><label class="text-danger">Invalid email format</label></p>'; } } if($error == '') { require 'phpmailer/class.phpmailer.php'; $mail = new PHPMailer(true); $mail->SMTPDebug = 1; // to see exactly what's the issue $mail->IsSMTP(); //Sets Mailer to send message using SMTP $mail->Host = 'hostname'; //Sets the SMTP hosts $mail->Port = '587'; //Sets the default SMTP server port $mail->SMTPAuth = true; //Sets SMTP authentication. Utilizes the Username and Password variables $mail->Username = 'emailaddress'; //Sets SMTP username $mail->Password = 'emailaddresspassword'; //Sets SMTP password $mail->SMTPSecure = ''; //Sets connection prefix. Options are "", "ssl" or "tls" $mail->From = $_POST["email"]; //Sets the From email address for the message $mail->FromName = $_POST["name"]; //Sets the From name of the message $mail->AddAddress('emailaddress', 'Name');//Adds a "To" address $mail->AddCC($_POST["email"], $_POST["name"]); //Adds a "Cc" address $mail->WordWrap = 50; //Sets word wrapping on the body of the message to a given number of characters $mail->IsHTML(true); //Sets message type to HTML $mail->Subject = "Online Badge Order"; //Sets the Subject of the message $mail->Body = "The order information is below" . "<br><br>" . "Club One: " . $_POST["club1"] . "<br>" . "Country One: " . $_POST["country1"] . "<br>" . "Ref No: " . $_POST["refno1"] . "<br>" . "Quantity: " . "<br>" . $_POST["quantity1"] . "<br>" . "Total Price Line: " . "\243" . $_POST["totalprice1"] . "<br><br>" . "Club Two: " . $_POST["club2"] . "<br>" . "Country Two: " . $_POST["country2"] . "<br>" . "Ref No: " . $_POST["refno2"] . "<br>" . "Quantity: " . $_POST["quantity2"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice2"] . "<br><br>" . "Club Three: " . $_POST["club3"] . "<br>" . "Country Three: " . $_POST["country3"] . "<br>" . "Ref No: " . $_POST["refno3"] . "<br>" . "Quantity: " . $_POST["quantity3"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice3"] . "<br><br>" . "Club Four: " . $_POST["club4"] . "<br>" . "Country Four: " . $_POST["country4"] . "<br>" . "Ref No: " . $_POST["refno4"] . "<br>" . "Quantity: " . $_POST["quantity4"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice4"] . "<br><br>" . "Club Five: " . $_POST["club5"] . "<br>" . "Country Five: " . $_POST["country5"] . "<br>" . "Ref No: " . $_POST["refno5"] . "<br>" . "Quantity: " . $_POST["quantity5"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice5"] . "<br><br>" . "Club Six: " . $_POST["club6"] . "<br>" . "Country Six: " . $_POST["country6"] . "<br>" . "Ref No: " . $_POST["refno6"] . "<br>" . "Quantity: " . $_POST["quantity6"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice6"] . "<br><br>" . "Club Seven: " . $_POST["club7"] . "<br>" . "Country Seven: " . $_POST["country7"] . "<br>" . "Ref No: " . $_POST["refno7"] . "<br>" . "Quantity: " . $_POST["quantity7"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice7"] . "<br><br>" . "Club Eight: " . $_POST["club8"] . "<br>" . "Country Eight: " . $_POST["country8"] . "<br>" . "Ref No: " . $_POST["refno8"] . "<br>" . "Quantity: " . $_POST["quantity8"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice8"] . "<br><br>" . "Club Nine: " . $_POST["club9"] . "<br>" . "Country Nine: " . $_POST["country9"] . "<br>" . "Ref No: " . $_POST["refno9"] . "<br>" . "Quantity: " . $_POST["quantity9"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice9"] . "<br><br>" . "Club Ten: " . $_POST["club10"] . "<br>" . "Country Ten: " . $_POST["country10"] . "<br>" . "Ref No: " . $_POST["refno10"] . "<br>" . "Quantity: " . $_POST["quantity10"] . "<br>" . "Total Price Line: " . "\243".$_POST["totalprice10"]; //An HTML or plain text message body if($mail->Send()) //Send an Email. Return true on success or false on error { header('Location:thank-you.html'); } else { $error = '<label class="text-danger">There is an Error</label>'; } $quantity1 = ''; $totalprice1 = ''; $subtotal = ''; $postage = ''; $grandtotal = ''; $name = ''; $addressline1 = ''; $postcode = ''; $email = ''; } } ?>
I am working on a webform that sends an email when submitted. The following output appears intermittently on the form.php page (I have currently disabled the page forwarding so I can see the output more easily). I am not quite sure what is going on, but when this occurs, no email is sent. Here's what the output looks like: Code: [Select] SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: MAIL not accepted from server: Message could not be sent. Mailer Error: SMTP Error: From address [myemail@myserver.com] failed This same file and same configuration has worked on and off, even when no changes are made. It seems that maybe the server is simply denying connections for some reason, but I'm not entirely sure, hence the post here. Any suggestions or ideas for debugging are GREATLY appreciated. Thanks! |