Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'email'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 9 results

  1. Hi there I hope you are well, Larry. I decided to re-visit my 'Contact us' page and review the spamscrubber. I was having trouble getting the spamscrubber to fish out the '\n's and '\r's to the extent that I changed the blank spaces to letters: function spam_scrubber($value) { //Create spam scrubber array.............. $very_bad = array('to:' , 'cc:' , 'bcc:' , 'content-type:' , 'mime-version' , 'multipart-mixed' , 'content-transfer-encoding:'); //For loop comparing email text to bad words....... foreach ($very_bad as $v) { //Look for bad word using stripos to ID the characters in the string. It will return a blank if found...... if (stripos($value, $v) !== false) { return 'AA'; } } $value = str_replace(array( "\r" , "\n" , "%0a" , "%0d"), 'BB' , $value); echo $value; return trim($value); } which made it easier to see what was going on. Thus my enquiry that included some '\n's and '\r's went through the email system WITH the '\n's and '\r's. So I then changed the code to (in red): function spam_scrubber($value) { //Create spam scrubber array.............. $very_bad = array('to:' , 'cc:' , 'bcc:' , 'content-type:' , 'mime-version' , 'multipart-mixed' , 'content-transfer-encoding:'); //For loop comparing email text to bad words....... foreach ($very_bad as $v) { //Look for bad word using stripos to ID the characters in the string. It will return a blank if found...... if (stripos($value, $v) !== false) { return 'AA'; } } $value = str_replace(array( "\\r" , "\\n" , "%0a" , "%0d"), 'BB' , $value); return trim($value); } and it works just fine. Thought I should let you know. Regards Max
  2. I would be grateful if anyone can suggest a useful guide to setting up mail with XAMPP/Mercury or any alternative mail program that I can try. I am running Windows 7 and just want to be able to send emails using PHP. I can get every script in Larry's book to work except for those involving email - 11.1, 13.1 and 18.6. I have downloaded all of the scripts from the website so I know the problem can't be with the scripts. I tried to follow a U tube video on setting up Mercury mail using demo@localhost but that didn't work either. I thought sending email in PHP was supposed to be easy, but it the most frustrating task of all. The scripts appear to work when I run them - I get the message "Thank you for contacting me..." but when I check my own email nothing ever arrives in my Inbox. Any suggestions what I can try next?
  3. I want to create a contact form that has an email field where the user can't enter any white space in the field, for example: test@ex ample.com I am using a spam scrubbing function taught to us in the book to clean user inputs. I am using my variable like so. $email = strip_tags($scrubbed['email']); how can I add something like this $email = preg_replace('/\s+/', '', $email); to the existing $email = strip_tags($scrubbed['email']); I tried $email = (preg_replace('/\s+/', '', $email)(strip_tags($scrubbed['email']))); and all sorts of variations to that. it doesn't work.
  4. I've generated a table of data using form data and the table needs to be emailed. How do you insert a php generated table into an email? I have a feeling that this could be achieved using javascript but I've never got comfortable with js so if it could be done with php, I would prefer to go that route. If you go to this link and fill in the form, you'll see the resulting table that needs to be included in an email. (There is validation on the form but if you input invalid data, you'll just get a blank screen as I'm working on the core functionality at the moment. ) I found these functions online function extract_id($content, $id) { // use mb_string if available if (function_exists('mb_convert_encoding')) { $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); } $dom= new DOMDocument(); $dom->loadHTML($content); $dom->preserveWhiteSpace = false; $element = $dom->getElementById($id); $innerHTML = innerHTML($element); return($innerHTML); } /** * Helper, returns the innerHTML of an element * * @param object DOMElement * * @return string one element's HTML content */ function innerHTML($contentdiv) { $r = ''; $elements = $contentdiv->childNodes; //line 77 foreach( $elements as $element ) { // line 78 if ( $element->nodeType == XML_TEXT_NODE ) { $text = $element->nodeValue; // IIRC the next line was for working around a // WordPress bug //$text = str_replace( '<', '<', $text ); $r .= $text; } // FIXME we should return comments as well elseif ( $element->nodeType == XML_COMMENT_NODE ) { $r .= ''; } else { $r .= '<'; $r .= $element->nodeName; if ( $element->hasAttributes() ) { $attributes = $element->attributes; foreach ( $attributes as $attribute ) $r .= " {$attribute->nodeName}='{$attribute->nodeValue}'" ; } $r .= '>'; $r .= innerHTML( $element ); $r .= "</{$element->nodeName}>"; } } return $r; } When I tried using them, I received these error messages, but I am uncertain what to pass as the argument. Would appreciate any help, thanks. Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/circuit/circuit.inc.php on line 77 Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/circuit/circuit.inc.php on line 78
  5. I've been using a script to check submissions for proper email formatting. It looks like this: eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) Note, that I didn't write this script, it was provided by someone else. It's worked fine for years, but now I'm getting an error message saying the function has been deprecated. I think my host must have installed a new version of PHP, 5.3.2. That's cool, I just need to figure out what to replace this code with. I've done a little research and it seems there are several ways to approach this, including: 1. just replace "eregi" with "preg_match." 2. use "filter_var" and "FILTER_VALIDATE_EMAIL" instead. Any advice as to what would be the best way to update this script would be greatly appreciated. Thanks!
  6. Hi. I'm using xampp 1.8.0 with Windows 7 SP1, 32 bit OS, and coding HTML5 and CSS3. I'm just learning PHP, and I created a contact form for a dentist's Website, so that patients can request appointments. An email should go to the dentist and display the information that the user entered. (I only coded the 'name' and 'description' to be in the email so far, since this is just a test.) I'm using Javascript to check if the patient filled out the form properly, so I didn't use some of the code shown on pg. 332 of the book. There is an error on the first line: Parse error: syntax error, unexpected 'POST' (T_STRING), expecting ']'. Can someone tell me what's wrong? Thanks. <?php if ($_SERVER['REQUEST_METHOD] == 'POST' { body = "Name: ($POST['name']}\n\nComments: {$_POST['description']}"; $body = wordwrap($body, 70); mail('mail@yahoo.com', 'Contact Form Submission', $body, "From: {$_POST['email']}"); echo 'Thank you for your request. A member of our staff will be contacting you shortly.'; $_POST = array(); } ?> <div id="form"> <div id="contain"> <form action="EmailConf.php" method="post"> <table class="form_demo"> <tr> <td> <label>Name</label> </td> <td> <input class="input_full" type="text" id="name" name="name" required="required" /> </td> </tr> <tr> <td><label for="email"> Email </label> </td> <td> <input class="input_full" type="email" id="email" name="email" required="required" /> </td> </tr> <tr> <td> <label for="tel"> Phone </label> </td> <td> <input class="input_full" type="tel" id="tel" name="tel" required="required" /> </td> </tr> <tr> <td><label for="priority_normal"> Priority </label> </td> <td> <input type="radio" name="priority" id="priority_urgent" value="Urgent"> <label for="priority_urgent"> Urgent </label> <input type="radio" name="priority" id="priority_normal" value="Normal" checked="checked"> <label for="priority_normal"> Normal </label> </td> </tr> <tr> <td> <label for="date">Enter a date:</label> </td> <td> <input class="input_xlarge" type="text" id="date" name="date" required="required" /> <script> (function($){ var pickerOpts = { minDate: new Date(), maxDate: "+3m,", showButtonPanel: true, showOn: "button", buttonImage: "images/cal.png", }; $("#date").datepicker(pickerOpts); })(jQuery); </script> </td></tr> <tr><td>Enter a time: </td> <td><input id="time1" name="s2Time1" /> <script type="text/javascript"> $('#time1').ptTimeSelect({ popupImage: 'Select Time' }); </script> </td> </tr> <tr> <td> <label for="description"> Reason for<br /> appointment </label> </td> <td> <textarea id="description" name="description" rows="3" required="required"></textarea> </td> </tr> </table> <hr /> <p class="clearfix"> <input type="submit" value="Submit" class="float_left" /> <input type="reset" value="Reset" class="float_right"> </p> </form>
  7. hi, i tried to send an email through a php code as given in the book but following error occured Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\email.php on line 47 i tried to fix it by trying alot of things searching from internet but can't solve .
  8. Hi Larry and other developers. I really hope someone can help me. I'm trying to do chapter 18 (I have read through the whole book but this is the first time I'm tried to do some of the code). I've installed xampp, started mercury (set up a new user) but that's all the mercury config I've done to mercury and xampp. I followed Larry's install guide from peachpits website (but didn't notice anything on mercury setup). I'm using php version 5.4.4. I'm very new to php though. So this is probably something really simple that I've missed or don't know about. In chapter 18 I'm on the register.php. I click submit at first I didn't see anything just a white space. So I commented out the first exit() and now I get the "thank you for registering" (data goes into the DB) but I don't get my email (my email addy is valid and I've checked spam etc Does anyone know what I've missed or what I can do to debug further? ... if (mysqli_affected_rows($dbc) == 1) { $body = "Thank you for registering \n\n You need to activate your account, Please click the following link to complete the registration process \n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'],'Registration', $body, 'From: online@xx.co.uk'); // exit(); //commented this out as I wasn't seeing the below text echo '<h3>Thank you for registering! A confirmation Email has been sent to your email address. Please click on the link in that email in order to active your account and access all the exclusive content!<h3>'; include ('includes/footer.html'); exit(); ... Really appreciate anyones/everyone help. So many thanks in advance, Regards, Alan
  9. I'm making a PHP newsletter sender, and I have multiple emails in a database. Is the following code the proper way to send multiple emails? So imagine that I have already done the MySQL call to retrieve all the emails, and I am now here: require_once "Mail.php"; require_once "Mail/mime.php"; $mail = new Mail_Mime(); $mime->setTXTBody('Text email'); $mime->setHTMLBody('HTML email'); $mime->setFrom('Sample Email Sender <sample@email.com>'); $mime->setSubject($subject); $body = $mime->get(); $headers = $mime->headers(); $smtp['host'] = 'smtp.emailserver.com'; $smtp['auth'] = true; $smtp['username'] = 'username@email.com'; $smtp['password'] = 'password'; $mail =& Mail::factory('smtp', $smtp); while($row = @mysqli_fetch_array($rq, MYSQLI_NUM)){$mail->send($row[0], $headers, $body);} unset($mime, $mail); You'll notice that what I did was set all the main email stuff outside of the while{} loop. Is this setup okay? Or do I need to move anything else into the while{} loop? Thanks again.
×
×
  • Create New...