Summary: Talk page for Mailform4.
Maintainer: MKonrad, AntonyTemplier (i18n)
Users: +2 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Failure sending email

24-Jun-2010 Allan?: This recipe looks like just what I'm looking for! But I'd like some help, please; I'm having a problem sending the email. I followed the instructions for installation (CAPTCHA and Mailform4). I tested that I got the warnings/errors as expected when I didn't enter values for Name, Email and Message (text). Captcha also works - I got the correct warning when I didn't get the captcha right. But when everything else is ok, the send fails with "Failure sending email."

I'm using PmWiki version pmwiki-2.2.16 (and the Choice Skin)

(Just an FYI, I noticed that in the file, there were two /cookbook/mailform4.php files. One looks like it's a previous version. I looked for the difference. The most recent version refers to, at some point, Mailform where the other refers to a generic Recipe Name.)

Thanks in advance for any help.

Update: 26-Jun-2010 Allan?: I found where the sending of the mail is failing, if not yet exactly why. At least the way I've installed it, the values for Recipient, Subject and Sender seem to be empty even though I set those in local.config. I haven't had time to work out why they're not being populated properly yet, but for now, what I did to get this going was to hard-code the values for those variables inside mailform4.php. Ouch, but at least I've got it working for now.
So the code in mailform4.php that looks like this:
       if (!mail(
          'From: ' . $Mailform4Sender))
I've set to something like this:
      if (!mail(
          'New message',
          'From: from My Website Contact Form'))
Luckily, the email that actually gets sent includes the values entered on the contact form for Your name, Your email address, and Your message, so you shouldn't lose any info typed in by the website visitor. Hope this helps someone! - Allan
MKonrad July 11, 2010, at 05:35 AM
Hi Allen, I examined my code again and found the bug... it's fixed now. Could you try it out again, please?
I also deleted the second mailform4 file. It was a .php~ file, that my editor automatically created as a backup.
Allan? July 14, 2010, at 12:20 PM
Hi, thanks for that. It's working now. Moved the new files across. Used the mailform twice and both worked. Before I sent the second, I changed the Subject and Recipient in the config.php file and the changes were reflected correctly on the email that I received. Good stuff. Thanks again for this recipe, much appreciated.

Cannot use the recipe when logged out

03-Dec-2012 Gao?: I have created admin groups in my pmwiki which requires a login to edit files. The recipe works (CAPTCHA images, proper error prompts, etc) when I am logged in as administrator. But it does not work if I am logged out as a random visitor (no CAPTCHA image, no error prompts on whatever input, no emails). Any hints? Thank you!

Antony Templier December 03, 2012, at 07:56 PM
- Check that both pages Mailform4.FormTemplate and Mailform4.MailTemplate are always readable by everybody.
- Try to add this at the end of your page url when you aren't logged as admin. : ?action=captchaimage&captchakey=2 . You should see juste an image in your browser's window instead of your page. If not, something prevents Captcha from making images.
Gao? December 03, 2012, at 09:48 PM
Thank you so much Antony for the quick respond! I confirm that both pages should be accessible to non-admin (chmod 775 Mailform4.*). I cannot see the image after I did what you instructed, but I can see it when logged admin. I would dig more but would be grateful to hear any of your further suggestions! The project I manage with pmwiki is on, if this additional piece of information would be useful in your kind help in troubleshooting. Thank you!
Antony Templier December 04, 2012, at 07:39 AM
In order to be sure of what's prevent Mailform4 to working properly, try these following steps :
1- Maybe PmWiki itself prevent you from reading the pages Mailform4.FormTemplate and Mailform4.MailTemplate : Check permissions by adding ?action=attr to the url of these both pages.
2- Edit the page Mailform4/FromTemplate and remove the line containing captcha stuff :
(:input form "{*$PageUrl}?action=mailform4" post:)
|| border=0
||$[Your name]: || (:input text size="50" name="mailform4[name]" value="{$Mailform4Name}":)||
||$[Your email address]:  || (:input text size="50" name="mailform4[sender]" value="{$Mailform4Sender}":)||
||$[Your message]: ||||
||(:input textarea name="mailform4[text]" value="{$Mailform4Text}" rows=10 cols=70:) ||||
||(:input submit value="$[Send message]":) ||||
(:input end:)
If you can send and receive an email : coockbook/mailform4.php is working well but not cookbook.captcha.php. Don't forget to restore (with ?action=diff) Mailform4/FromTemplate before to continue.
3- If you use $GroupPattern variable in you're local/config.php be sure to include Mailform4 group, ex : $GroupPattern='(?-i:Site|SiteAdmin|Profiles|PmWiki|Main|...|Mailform4)';
4- You told that all works fine when you 're logged as admin, so all php dependencies are satisfied for generating images (GD Support). But to be sure, you can try to add $EnableCaptchaImage=0; just before including cookbook/captcha.php in your local/config.php. This enable captcha to work with pure ascii text instead images.
5- In your case, it can be something related to php @$_SESSION variable because captcha.php use it and because it's related to the way you are logged to pmwiki. Try to check Pmwiki permissions (with ?action=attr) that aren't the same for random user and admin.
6- At this point it's hard for me to investigate more without acessing files of the real installation. Try to setup a new pure blank pmwiki with just the two recipes cookbook/captcha.php and cookbook/mailform4.php and setup your admin groups and security setup step by step. Check your mail form between each step and get which one break the form.

Mailform4 changes size of textarea when editing pages

3rd October 2013 - Paul Herber - paul at pherber dot com

After installing Mailform4 with Captcha (this all works wonderfully), opening the edit form for any page creates a very small text edit area, only 3 lines high, though the area can be increased using the resize handle. Looking at the source code generated for the edit form the cols and rows attributes are incorrect, 'e_rows' and 'e_cols' instead of the normal '10' and '70'.

AntonyTemplier October 03, 2013, at 07:30 AM
'e_rows' and 'e_cols' are the name of variables that define the size of cols and row attribute of the textarea tag for the edit form. These are set by default in the scripts/forms.php file to : e_rows = 23 and e_cols = 60. Then they are overwriten by the page in Site.Preferences (default to e_rows = 20 and e_cols = 70) or can be in an XLPage. Update 2013-10-08 : MailForm4 and Captcha don't change nor use them at all. Try to uninstall MailForm4 and see if your mistake is still here. If not give us more informations in order to investigate.. See my next comment below.

Many thanks for the quick update. All works fine now. - Paul Herber

Text input area reduced after installing this recipe

After properly installing this recipe I found that this recipe does indeed cause the text input box for ?action=edit to be reduced to two lines on all pages of my wiki. I separate recipe installations with extensive testing and triple-checking, so I'm confident that Mailform4 caused the reduction in lines for the edit text input box (?action=edit). Also, the wikilib.d directory is not the best place for the core recipe pages MailForm and MailTemplate because that's part of the upgrade tree and should not be modified by users or recipes.
IanMacGregor October 07, 2013 at 01:35 PM

AntonyTemplier October 07, 2013, at 06:09 PM
Try the new version 2013-10-08. Just replace the cookbook/mailform4.php. A bug mess up the $XLLangs array used by the XLPage function that translate the e_rows and e_cols variables. And as you suggested wiki pages have been moved to the wiki.d dir.
I've reinstalled this new version and it works perfectly on my wiki running pmwiki-2.2.56, the previous bug has indeed been resolved. Thank you very much for the fast response and updated recipe. I also like that the last line in Mailform4.MailTemplate can be edited to provide for user needs. Much appreciated! IanMacGregor October 07, 2013 at 06:16 PM
AntonyTemplier July 20, 2015, at 08:43 AM
Note : Since the 2015-07-20 version, the wiki pages (MailTemplate, FormTemplate and translations) have been removed from wiki.d to wikilib.d again ( to prevent to overwrite user's customizations when upgrading ). You can have your own configuration by creating your wiki.d/MailTemplate and wiki.d/FormTemplate ( which will overwrite page in wikilib.d ).

About the styling of validation messages.

I tried using the styling suggested in the recipe but it isn't working in my CSS file. I tried it with div.info_msg and .info_msg but neither are working as classes in my CSS file. Could someone take a look and perhaps provide more information on how to style the validation messages? IanMacGregor October 07, 2013 at 10:45 PM

Everything seems ok with div.info_msg and .info_msg css code on a vanilla new pmwiki installation (2.2.56). Perhaps your file .tmpl in your skin directory has changed the way to target the tags :<div class="error_msg"> and <div class="info_msg"> ?
Tips : add ?action=mailform4&success=1 or ?action=mailform4&success=0 at the end of the url to show how looks feedback messages of mailform4 without sending mail.
AntonyTemplier October 08, 2013, at 02:30 AM
It's working now, might have been a cache issue with my browser or something. Thank you very much for making a way for the end-user to style these messages, very much appreciated. IanMacGregor October 08, 2013 at 09:22 AM

Talk page for the Mailform4 recipe (users).