Jump to content

Simple Contact Form


justb3a

Recommended Posts

I have installed the module and the page appears as expected. The submit button works and redirects to the success page, or not if it detects spam.

No emails are sent and I get the following errors in the log:

[ERROR] Mail has not been sent to Name 

[ERROR] Additional mail could not be sent to Name

running PW 3.0.123 on PHP 7.1.31

I have searched the forum for a solution. Can anyone suggest where else I might look to solve this?

Link to comment
Share on other sites

In a local environment like Laragon you have to enable mail-catcher or an external SMTP.
In case of MAMP there may be similar settings.

With a local Linux environment you most likely will need sendmail, msmtp or a similar setup.

When this happens on a regular hosting plan your provider might have disabled this feature.

I'd recommend a look at WireMail: SMTP as it uses an external SMTP server/mail account (which you define).

I'd say it's the most reliable way to send emails from within ProcessWire. But that's just my opinion.

Link to comment
Share on other sites

Thanks wbmnfktr,
you put me on the right track. I had WireMail: SMTP installed but not configured. I actually uninstalled the module and emails are now being sent. 

I am having an issue where an email is sent to my address, but not to the person using the Contact form. 

The following is in the contact page template:

<?php $scf = $modules->get('SimpleContactForm');
$options = array(
'btnClass' => 'butn1',
'btnText' => 'Send',
'emailMessage' => 'You have successfully sent a message to Rob',
'item_label' => "",
'classes' => array(
'item' => 'input-field'
)
);
echo $scf->render($options); ?>
<br ><br ><br ></div> </div>
<?php include('./includes/foot.inc'); ?>

 Any clues would be appreciated.

Link to comment
Share on other sites

1 hour ago, Rob(AU) said:

but not to the person using the Contact form.

So you want to send a copy to the website visitor itself?
Never tried it but... you can define additional recipients within the options and maybe even from within a hook.

<?php
$this->addHookBefore('SimpleContactForm::sendAdditionalMail', function(HookEvent $event) {
  $form = $event->arguments(0);
  $emailCopy = $form->get('scf_emailcopy');

  // more logic here

});

More details and another hook example at the bottom of the page: https://github.com/justb3a/processwire-simplecontactform

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

Im usin SCF and I'm getting a lot of spam lately, is there any captcha or something else available for this. I'm not a coder so not really sure how to solve this on my own.

My code right now is:

              <?php $scf = $modules->get('SimpleContactForm');
					$options = array(
					  'btnClass' => 'sc_button sc_button_style_filled sc_button_size_medium',
					  'btnText' => 'Po&#353;lji',
					  'classes' => array(
						'item' => 'sc_form_item sc_form_field label_over'
					  )
					);
				echo $scf->render($options);

				?>

Any help is appreciated 😉

R

Link to comment
Share on other sites

  • 2 weeks later...
On 10/17/2019 at 7:25 PM, Roych said:

Hello,

Im usin SCF and I'm getting a lot of spam lately, is there any captcha or something else available for this. I'm not a coder so not really sure how to solve this on my own.

My code right now is:


              <?php $scf = $modules->get('SimpleContactForm');
					$options = array(
					  'btnClass' => 'sc_button sc_button_style_filled sc_button_size_medium',
					  'btnText' => 'Po&#353;lji',
					  'classes' => array(
						'item' => 'sc_form_item sc_form_field label_over'
					  )
					);
				echo $scf->render($options);

				?>

Any help is appreciated 😉

R

Are you using the honeypot technique as described here?

Link to comment
Share on other sites

I'm also getting a lot of spam lately. Due to previous issues my code is a bit different, and not so clear where/how to add the honeypot field. This is the contact page template code:

	$scf = $modules->get('SimpleContactForm');

	$options = array(
	'emailMessage' => "{$input->scf_name} from {$input->scf_location} with IP {$input->scf_ip} sent this message:   	
	{$input->scf_message}",
	'emailFrom' => $input->scf_email,
	'emailSender' => $input->scf_email,
	'emailReplyTo' => $input->scf_email,
	'markup' => array(
    'list' => "<div {style='width:75%;'}>{out}</div>",
    'item' => "<p {attrs}>{out}</p>"
    ),
	'classes' => array(
    'form' => 'form BFD_contact',
    'list' => 'list-item'
	)
	);

	echo $scf->render($options);

Thanks for any help.

Link to comment
Share on other sites

  • 8 months later...

Hi! I'm learning more about ProcessWire and PHP in general by practicing on the different modules.

I created a test form using the SimpleContactForm module and just adding 1 text field, 1 image upload and 1 file upload field. I've alternated between just one or the other and having both uploads.

Without the upload fields, the form gets handled correctly and is stored as a page, however when I add an upload field it returns the following error:

Fatal error: Uncaught Error: Call to a member function path() on null in C:\xampp\htdocs\avanzademo\wire\modules\Fieldtype\FieldtypeFile.module:220 Stack trace: #0 C:\xampp\htdocs\avanzademo\wire\core\WireHooks.php(924): ProcessWire\FieldtypeFile->hookProcessInput(Object(ProcessWire\HookEvent)) #1 C:\xampp\htdocs\avanzademo\wire\core\Wire.php(450): ProcessWire\WireHooks->runHooks(Object(ProcessWire\InputfieldImage), 'processInput', Array) #2 C:\xampp\htdocs\avanzademo\wire\core\InputfieldWrapper.php(961): ProcessWire\Wire->__call('processInput', Array) #3 C:\xampp\htdocs\avanzademo\wire\modules\Inputfield\InputfieldForm.module(155): ProcessWire\InputfieldWrapper->___processInput(Object(ProcessWire\WireInputData)) #4 C:\xampp\htdocs\avanzademo\wire\core\Wire.php(383): ProcessWire\InputfieldForm->___processInput(Object(ProcessWire\WireInputData)) #5 C:\xampp\htdocs\avanzademo\wire\core\WireHooks.php(823): ProcessWire\Wire->_callMethod('___processInput', Array) #6 C:\xampp\htdocs\avanzademo\wire\core\Wire.php(450): ProcessWi in C:\xampp\htdocs\avanzademo\wire\modules\Fieldtype\FieldtypeFile.module on line 220

I've been looking into the mentioned files but can't seem to find the exact error. I also looked through a couple of the posts already discussing similar issues in the forum but I can't quite pinpoint what would be a viable solution for this. 

If anyone can help point me in the right direction, I'd greatly appreciate it.

Link to comment
Share on other sites

Hi @Nicole Bardales 

I don't have a solution for you yet, but a recommendation that might help: Install TracyDebugger and you'll get a better output of your error and also some great tools for debugging your scenario. For example you can add bd($var) calls in your code and get a nice visual dump of your variable and can then track the issue down.

It is a great tool for learning PW and PHP in general because it makes a lot of things visible that are usually hidden somewhare in the memory 🙂 

Hope that helps a little 🙂 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi,

I'm having troubles hiding the scf-website, I created a form.php with the following:

<?php namespace ProcessWire; ?>

<div class="form__item form__item--scf-website" id="wrap_Inputfield_scf-website" id='content'>
	<?php
	echo $modules->get('SimpleContactForm')->render(); 
	?>
</div>

I can't seem to hide the scf-website field, what should I add to the CSS?

Link to comment
Share on other sites

30 minutes ago, sjaaksken said:

I can't seem to hide the scf-website field, what should I add to the CSS?

First, if you want to wrap the module render code in a div, don't use that class and id (and don't use 2 ids for the same element). Once the form is rendered, you'll see that there is already a div with that class that wraps the field you wish to hide. In the CSS, just target that class:

.form__item--scf-website { display: none; }

Link to comment
Share on other sites

  • 8 months later...

@PWaddict Yes, I've got it working. I made a simple InputField that works with FlyDev's MarkupGoogleRecaptcha module so the reCaptcha can be added to the SimpleContactForm. Then, using the info on the SFC instructions page, I added the following hood to my ready.php file. I've attached the zip file of my field type if you want to take a look. I'm no expert, but I based it on another simple module.

$this->addHookBefore('SimpleContactForm::processValidation', function(HookEvent $event) {
  $form = $event->arguments(0);
  $recaptcha = $form->get('recaptcha');
  
  if (!$this->input->post->{'g-recaptcha-response'}) { // attach an error to the field
    $recaptcha->error(__('You didn\'t pass the reCaptcha test.')); // it will be displayed along the field
  }
});

 

FieldtypeRecaptcha.zip

  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...

I need some help..

I´m trying to get the value of an select option field to display in the mail.

This is my code

  <?php
        $scf = $modules->get( 'SimpleContactForm' );
          
        $options = array(            
          'offert_typeoffacility' => 'offert_typeoffacility->title',
          'btnText' => 'Skicka förfrågan'
        );
        echo $scf->render( $options );
        ?>

And the "offert_typeoffacility" is the select option field. But it only renderering the value ID instead of the title?

I tried also the message option in the module backend.

Typ av fastighet: %offert_typeoffacility% but it only rendering the same ID.

Do you guys have any solution to this? Please help

Link to comment
Share on other sites

@Flashmaster82 I've just had a look at how I did this before. I used a select option field to list a booking times (10:00am, 10:30am,  etc). I probably got this from someone else on these forums because my comments for the code were more detailed than I usually do! 

Rather than use the message in the module settings, override it and use a message.php file:

	$scf = $modules->get('SimpleContactForm');
	include("./message.php");
	$options = array(
	  'emailMessage' => $emailMessage,
	   ...

Note: you shouldn't need 'offert_typeoffacility' => 'offert_typeoffacility->title' in the options.

In message.php, sanitise and get the field title like this:

   $facility  = $sanitizer->int($input->post->offert_typeoffacility);
   // (other fields)...

   // To get the value of an Options Field Type, you need to
   // first get the id submitted
   // then get all the options for that field
   // then use the eq for that option to get the title (eq starts with 0, so subtract 1 from the id)
   $field = $fields->get('offert_typeoffacility');
   $all_options = $field->type->getOptions($field);
   $theFacility = $all_options->eq($facility - 1)->title;

   $emailMessage = "Hello,
		Option: {$theFacility}
		... ";

I try to use Page Reference fields for SimpleContactForm selects now because it's even easier: $theFacility = $pages->get($facility)->title;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By monollonom
      (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website 😅. Thx @teppo !)
      FieldtypeQRCode
      Github: https://github.com/romaincazier/FieldtypeQRCode
      Modules directory: https://processwire.com/modules/fieldtype-qrcode/
      A simple fieldtype generating a QR Code from the public URL of the page, and more.
      Using the PHP library QR Code Generator by Kazuhiko Arase.

      Options
      In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default.
      You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field.
      If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated.
      Formatting
      Unformatted value
      When using $page->getUnformatted("qrcode_field") it returns an array with the following structure:
      [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value
      The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup.
      Should you need the same markup as in the admin you could use:
      $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value.
      Static QR code generator
      You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are:
      string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks
      Please have a look at the source code for more details about the hookable functions.
      Examples
      $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
×
×
  • Create New...