Jump to content

horst

PW-Moderators
  • Posts

    4,077
  • Joined

  • Last visited

  • Days Won

    87

Everything posted by horst

  1. Wire Mail SMTP An extension to the (new) WireMail base class that uses SMTP-transport This module integrates EmailMessage, SMTP and SASL php-libraries from Manuel Lemos into ProcessWire. I use this continously evolved libraries for about 10 years now and there was never a reason or occasion not to do so. I use it nearly every day in my office for automated composing and sending personalized messages with attachments, requests for Disposition Notifications, etc. Also I have used it for sending personalized Bulkmails many times. The WireMailSmtp module extends the new email-related WireMail base class introduced in ProcessWire 2.4.1 (while this writing, the dev-branch only). Here are Ryans announcement. Current Version 0.8.0 (from 2024-09-25 -- initial version 0.0.1 was pushed on 2014-03-01) Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md Downlod: get it from the Modules Directory || fetch it from Github || or use the module-installer in PWs admin site modules panel with its class name "WireMailSmtp". Install and Configure Download the module into your site/modules/ directory and install it. In the config page you fill in settings for the SMTP server and optionaly the (default) sender, like email address, name and signature. You can test the smtp settings directly there. If it says "SUCCESS! SMTP settings appear to work correctly." you are ready to start using it in templates, modules or bootstrap scripts. Usage Examples The simplest way to use it: $numSent = wireMail($to, $from, $subject, $textBody); $numSent = wireMail($to, '', $subject, $textBody); // or with a default sender emailaddress on config page This will send a plain text message to each recipient. You may also use the object oriented style: $mail = wireMail(); // calling an empty wireMail() returns a wireMail object $mail->to($toEmail, $toName); $mail->from = $yourEmailaddress; // if you don't have set a default sender in config // or if you want to override that $mail->subject($subject); $mail->body($textBody); $numSent = $mail->send(); Or chained, like everywhere in ProcessWire: $mail = wireMail(); $numSent = $mail->to($toEmail)->subject($subject)->body($textBody)->send(); Additionaly to the basics there are more options available with WireMailSmtp. The main difference compared to the WireMail BaseClass is the sendSingle option. With it you can set only one To-Recipient but additional CC-Recipients. $mail = wireMail(); $mail->sendSingle(true)->to($toEmail, $toName)->cc(array('person1@example.com', 'person2@example.com', 'person3@example.com')); $numSent = $mail->subject($subject)->body($textBody)->send(); The same as function call with options array: $options = array( 'sendSingle' => true, 'cc' => array('person1@example.com', 'person2@example.com', 'person3@example.com') ); $numSent = wireMail($to, '', $subject, $textBody, $options); There are methods to your disposal to check if you have the right WireMail-Class and if the SMTP-settings are working: $mail = wireMail(); if($mail->className != 'WireMailSmtp') { // Uups, wrong WireMail-Class: do something to inform the user and quit echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; return; } if(!$mail->testConnection()) { // Connection not working: echo "<p>Couldn't connect to the SMTP server. Please check the {$mail->className} modules config settings!</p>"; return; } A MORE ADVANCED DEBUG METHOD! You can add some debug code into a template file and call a page with it: $to = array('me@example.com'); $subject = 'Wiremail-SMTP Test ' . date('H:i:s') . ' äöü ÄÖÜ ß'; $mail = wireMail(); if($mail->className != 'WireMailSmtp') { echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; } else { $mail->from = '--INSERT YOUR SENDER ADDRESS HERE --'; // <--- !!!! $mail->to($to); $mail->subject($subject); $mail->sendSingle(true); $mail->body("Titel\n\ntext text TEXT text text\n"); $mail->bodyHTML("<h1>Titel</h1><p>text text <strong>TEXT</strong> text text</p>"); $dump = $mail->debugSend(1); } So, in short, instead of using $mail->send(), use $mail->debugSend(1) to get output on a frontend testpage. The output is PRE formatted and contains the areas: SETTINGS, RESULT, ERRORS and a complete debuglog of the server connection, like this one: Following are a ... List of all options and features testConnection () - returns true on success, false on failures sendSingle ( true | false ) - default is false sendBulk ( true | false ) - default is false, Set this to true if you have lots of recipients (50+) to ($recipients) - one emailaddress or array with multiple emailaddresses cc ($recipients) - only available with mode sendSingle, one emailaddress or array with multiple emailaddresses bcc ($recipients) - one emailaddress or array with multiple emailaddresses from = 'person@example.com' - emailaddress, can be set in module config (called Sender Emailaddress) but it can be overwritten here fromName = 'Name Surname' - optional, can be set in module config (called Sender Name) but it can be overwritten here priority (3) - 1 = Highest | 2 = High | 3 = Normal | 4 = Low | 5 = Lowest dispositionNotification () or notification () - request a Disposition Notification subject ($subject) - subject of the message body ($textBody) - use this one alone to create and send plainText emailmessages bodyHTML ($htmlBody) - use this to create a Multipart Alternative Emailmessage (containing a HTML-Part and a Plaintext-Part as fallback) addSignature ( true | false ) - the default-behave is selectable in config screen, this can be overridden here (only available if a signature is defined in the config screen) attachment ($filename, $alternativeBasename = "") - add attachment file, optionally alternative basename send () - send the message(s) and return number of successful sent messages debugSend(1) - returns and / or outputs a (pre formatted) dump that contains the areas: SETTINGS, RESULT, ERRORS and a complete debuglog of the server connection. (See above the example code under ADVANCED DEBUG METHOD for further instructions!) getResult () - returns a dump (array) with all recipients (to, cc, bcc) and settings you have selected with the message, the message subject and body, and lists of successfull addresses and failed addresses, logActivity ($logmessage) - you may log success if you want logError ($logmessage) - you may log warnings, too. - Errors are logged automaticaly useSentLog (true | false) - intended for usage with e.g. third party newsletter modules - tells the send() method to make usage of the sentLog-methods - the following three sentLog methods are hookable, e.g. if you don't want log into files you may provide your own storage, or add additional functionality here sentLogReset () - starts a new LogSession - Best usage would be interactively once when setting up a new Newsletter sentLogGet () - is called automaticly within the send() method - returns an array containing all previously used emailaddresses sentLogAdd ($emailaddress) - is called automaticly within the send() method Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md
  2. Ryan, I would like to have the possibility not to use only the Emailaddress but also the Recipients Names with the TO-array. Actually it accepts only a single emailaddress or an array with emailaddresses, but no names. When building that on my own I would have to break compatibility. Don't like that. Could we not use something like: public function to($email) { if(!is_array($email)) $email = explode(',', $email); $this->mail['to'] = array(); // clear // check for key-value pairs containing name=>email if(array_keys($email) !== range(0, count($email) - 1)) { foreach($email as $n=>$e) { $this->mail['to'][$n] = $this->sanitizeEmail($e); } } else { foreach($email as $e) { $this->mail['to'][] = $this->sanitizeEmail($e); } } return $this; } // also within the send() function we have to check if we have array with name=>email or string only with email I'm not happy with my code example. A better way is much appreciated, but I really would like to have that possibility. ---------------------------------------------------------- - EDIT ---------------------------------------------------------- Now after some testing I came up with this code what seems to be better: public function to($email) { if(!is_array($email)) $email = explode(',', $email); $this->mail['to'] = array(); // clear foreach($email as $n=>$e) { // check for associative key-value pairs containing name=>email if(is_string($n)) { $this->mail[$type][$this->sanitizeHeader($n)] = $this->sanitizeEmail($e); } else { $this->mail['to'][] = $this->sanitizeEmail($e); } } return $this; } And in the send() function we need to loop like this: $numSent = 0; foreach($this->to as $n=>$to) { $to = !is_string($n) ? $to : ( $n . ' <' . $to . '>' ); if(mail($to, $this->subject, $body, $header, $param)) $numSent++; }
  3. I don't have a static IP and I use a special string within the UserAgent, for example: RewriteCond %{HTTP_USER_AGENT} !^.*(b346a0b6fe9d440d68e07c9619c0ba0a).*$ This way (with switching UserAgent of the browser) I am able to look to the site as admin and like the public from the same IP.
  4. Yes it is working well. I have a site on a shared host where I have got sometimes this "2006 Server has gone away" error, especially when the client was working in the admin with large pagelists (he wants to have the default limit of 50 increased to 200). But this wasn't the only time when this happens. Now after update it with your patch I think we have to wait a week or two to be really sure it is solved. But actually I think yes it will be!
  5. Many thanks. Have installed it.
  6. Ok, give me a few from your accounts around the web.
  7. That's correct, it's not the best but the badest solution! http://plaintextoffenders.com/
  8. Oh good you have some progress! Have you different PHP-Versions for local and online? Password recovery or reset
  9. Sorry, I cannot really follow what you have done There are good explanation in the API with the Hello World module and many related posts here in the forums. If you want to search for something you should not use the forums search. Instead you should use google with queries like: site:processwire.com/talk write my own module (the 'site:processwire.com' part is important). If you only want to search in the forums you add a /talk to the domain, etc. You also may ask Felix what he want do with hybridAuth and if he plan / is able to share his work.
  10. what page do you try to access? where is it (url)? which part generate the error? do you have additional code for pw running not only the include? if yes, comment it out - you need to go step by step for trouble shooting. BTW: I have edited my post above, I think bootstrapping isn't the way you have to go here.
  11. Normaly there should be no conflict: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Session.php#L9 But how have you done it? Included PW at the first line, - or somewhere in between? Have you logged a var_dump of $_SESSION and wire('session') or have you tried to use the global var $session what is not available in bootstraped scripts? Have you logged it before and after bootstrapping PW, if you do not include it at first? It depends on the code of the hybridauth-script where to look for potential conflicts. Have you turned debug on? Any errors? Have you outputted / logged errors from the hybridauth script? What does not work, what is different running it without pw? A few details surely could help people to help you ;-) --------------------------------------------------------------------------------------------------------------------------------------- EDIT: After reading a bit of that stuff it seams to me that the way to go should be: forget about calling a external script write a module that hooks into Session::authenticate use a few lines of code from the hybridauth-API to authenticate through a provider Additional to the above basics you have to build a layer where you list the providers you want to use for authentication. The user first need to select one. Maybe you need to hook into Session::login instead of Session::authenticate, but you will find out if you start testing
  12. Hi Charles, the site is looking great. At first I like the colors, don't really know why! (just kidding) The screen of the information portal is suuuuper. While one can only guess what is behind it, it is not much imagination required to come to the conclusion that certainly it makes fun to work with it. Impressive work.
  13. Hi Helmut, you may create a new template with its own template file. Create a blank textfile and call it myform.php, copy it into the site/templates/ folder of pw. Go into the pw admin and under setup templates and create a new template. There should be a list with template filenames from your site/templates/ folder (without the .php extension). Check the one you have newly created and save it. Now create a new page under homepage and assign your form-template to it. Lets say the url of it is "/contactform/". Go to your Editor and write into your template file some code like that: <?php if($input->post->aFormFieldName) { // a user has send the form, proceed the data and display a thank you message ... echo "<h4>Thank you for contacting us. We will get back to you soon."; return; // stop with template code here } // if we have no post data, lets display a html form $myForm1 = " <form action='{$page->url}' method='post'> // your inputfields and buttons here </form> "; echo $myForm1; Now go to the browser and call: example.com/contactform/ and try it out. If you use a profile with header.inc and footer.inc, add it to the template file like it is within the other template files: <?php include("./head.inc"); if($input->post->aFormFieldName) { // a user has send the form, proceed the data and display a thank you message ... echo "<h4>Thank you for contacting us. We will get back to you soon."; include("./foot.inc"); // load the footer here, because we stop template execution in the next line! return; // stop with template code here } // if we have no post data, lets display a html form $myForm1 = " <form action='{$page->url}' method='post'> // your inputfields and buttons here </form> "; echo $myForm1; include("./foot.inc"); Have fun!
  14. I really like all the minify and less support. Actually I use the Spex-Module from Jonathan. With the next project I want to use AIOM+. Only one question for me is if it is an improvement to use domain sharding today. Before 2010, max 2 simultaneous connections was allowed. Today 6-8 are allowed/used. Without images you may need 1 html + 1 css + 1 js + 1 optional for Fonts = 4 related article: http://www.mobify.com/blog/domain-sharding-bad-news-mobile-performance/
  15. horst

    Satu

    Thank you for the explanation and link to sequence-js. But I think sequence.js would be to much overhead for a little Ken-Burns effect. To write a own small script is a much better way
  16. horst

    Satu

    Hi Fokke, really great site. Very good presentation and modern design. Most I like the moving of the slideshow images on the homepage. Is this realized with a jQuery-Plugin only, or is this mainly a CSS3-animation/transition thing? (I'm not very familiar with this stuff)
  17. http://processwire.com/talk/topic/3543-register-users-and-add-page-same-as-username/#entry34854
  18. also worth a look: http://processwire.com/talk/topic/3812-htaccess/?p=37295
  19. @adrian: if the actual page isn't in $pids, there is no need to load page 1114 into memory $pids = array(1010, 1011, 1022); if(in_array($page->id, $pids)) { $downloads = $pages->get("1114"); echo "$downloads->body"; }
  20. This thread also covers a part of that: http://processwire.com/talk/topic/5573-hook-for-sending-mail/
  21. Yes, that's right. I use a 404 log with file: public function init() { $this->addHookBefore('ProcessPageView::pageNotFound', $this, 'hookLog404Errors'); } public function hookLog404Errors() { // determine the URL that wasn't found $url = $_SERVER['REQUEST_URI']; // if installed in a subdirectory, make $url relative to the directory ProcessWire is installed in if($this->config->urls->root != '/') { $url = substr($url, strlen($this->config->urls->root)-1); } $ua = isset($_SERVER['HTTP_USER_AGENT']) ? substr(trim(strip_tags($_SERVER['HTTP_USER_AGENT'])),0,240) : ''; $this->log->save('404-errors', "{$url} \t :: \t {$ua}"); } The API variable $log was introduced with 2.3.1-dev and is available in 2.4 stable now: http://processwire.com/talk/topic/3768-processwire-231-dev-branch/
  22. I haven't read your code of the project. Just want point out that: If you have to call PHP scripts directly (not include them), with it's URL, you cannot store them into the sites/... folder. If it is only one script, you may place it into the root besides the index.php of pw. Also if you want / have to collect some output from that script within pw, you can bootstrap PW within that script, store a result into a $session->var and also use $session->redirect according to that output, if you need that.
  23. You may do this by a module like that: public function init() { $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListLabelItems'); } public function addPageListLabelItems($event) { $page = $event->arguments('page'); // then you do your conditionals and your styling, like for example: if($page->myField >= $myMinValue && $page->myField <= $myMaxValue) { // add your styling here } // or like that: if('architekt'==$page->template) { // add the styling here $styleItem = $page->ortarchitekt == '' ? ' <span class="jhpPageListItemEmpty"><strong style="color:white">kein Ort eingetragen</strong></span> ' : ''; // now add the new style item to the existing output $event->return = $event->return . $styleItem; } } This way I get outputs like that: EDIT: Ah, have found it: here is a module from Soma: http://modules.processwire.com/modules/page-list-image-label/ that adds a Thumbnail to the list. That was the startingpoint for my customized PagetreeList. If you are not (yet) familiar with modules please have a look to the HelloWorld-Module or ask here for further assistance
  24. but seems that Ryan need to increase it. When trying to send a PM to Ryan I get this errors:
×
×
  • Create New...