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

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 kixe
      Field that stores one or more references to ProcessWire pages with additional data in field context.
      Values are editable via page edit modal of the referenced page provided from the field if module AdminPageFieldEditLinks is installed and "Enable link to create new pages?" is checked in field settings.
      Requirements: AdminPageFieldEditLinks >= 3.1.4
      https://github.com/kixe/FieldtypePageContextData
      https://processwire.com/modules/fieldtype-page-context-data/
      Use case example:
      The planning of the Tonmeistertagung in the CCD (Congress Center Düsseldorf) from November 3rd, 2021 to November 6th, 2021 is in the finalization phase.
      The conference consists of a conference part and an exhibition. The planning is done via a separate frontendless PW instance. There, all companies (pages) that are active at various events are kept in a pool. Changes (address, logo) can always be done there. For the exhibition of the current conference in November, the exhibitor-companies (pages) are selected via a page reference field. A stand number must now be assigned to each selected company (page). We had originally solved this using the Profield FieldtypeTable. However, this had the disadvantage that each entry again made all companies available for selection and did not recognize which were already selected in a previous table row. The new field type now allows the value (company's stand number) to be assigned to a Company (page) in context to a specific Pagefield living in a specific page.
      https://tonmeistertagung.com/en/exhibitors/exhibition/
       
    • By Robin S
      This module lets you add some custom menu items to the main admin menu, and you can set the dropdown links dynamically in a hook if needed.
      Sidenote: the module config uses some repeatable/sortable rows for the child link settings, similar to the ProFields Table interface. The data gets saved as JSON in a hidden textarea field. Might be interesting to other module developers?
      Custom Admin Menus
      Adds up to three custom menu items with optional dropdowns to the main admin menu.
      The menu items can link to admin pages, front-end pages, or pages on external websites.
      The links can be set to open in a new browser tab, and child links in the dropdown can be given an icon.
      Requires ProcessWire v3.0.178 or newer.
      Screenshots
      Example of menu items

      Module config for the menus

      Link list shown when parent menu item is not given a URL

      Advanced
      Setting child menu items dynamically
      If needed you can set the child menu items dynamically using a hook.
      Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $colours = $event->wire()->pages->findRaw('template=colour', ['title', 'url', 'page_icon']); $children = []; foreach($colours as $colour) { // Each child item should be an array with the following keys $children[] = [ 'icon' => $colour['page_icon'], 'label' => $colour['title'], 'url' => $colour['url'], 'newtab' => false, ]; } $event->return = $children; } }); Create multiple levels of flyout menus
      It's also possible to create multiple levels of flyout submenus using a hook.

      For each level a submenu can be defined in a "children" item. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $children = [ [ 'icon' => 'adjust', 'label' => 'One', 'url' => '/one/', 'newtab' => false, ], [ 'icon' => 'anchor', 'label' => 'Two', 'url' => '/two/', 'newtab' => false, 'children' => [ [ 'icon' => 'child', 'label' => 'Red', 'url' => '/red/', 'newtab' => false, ], [ 'icon' => 'bullhorn', 'label' => 'Green', 'url' => '/green/', 'newtab' => false, 'children' => [ [ 'icon' => 'wifi', 'label' => 'Small', 'url' => '/small/', 'newtab' => true, ], [ 'icon' => 'codepen', 'label' => 'Medium', 'url' => '/medium/', 'newtab' => false, ], [ 'icon' => 'cogs', 'label' => 'Large', 'url' => '/large/', 'newtab' => false, ], ] ], [ 'icon' => 'futbol-o', 'label' => 'Blue', 'url' => '/blue/', 'newtab' => true, ], ] ], [ 'icon' => 'hand-o-left', 'label' => 'Three', 'url' => '/three/', 'newtab' => false, ], ]; $event->return = $children; } }); Showing/hiding menus according to user role
      You can determine which menu items can be seen by a role by checking the user's role in the hook.
      For example, if a user has or lacks a role you could include different child menu items in the hook return value. Or if you want to conditionally hide a custom menu altogether you can set the return value to false. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); $user = $event->wire()->user; // For custom menu number 1... if($menu_number === 1) { // ...if user does not have some particular role... if(!$user->hasRole('foo')) { // ...do not show the menu $event->return = false; } } });  
      https://github.com/Toutouwai/CustomAdminMenus
      https://processwire.com/modules/custom-admin-menus/
    • By tcnet
      This module for ProcessWire sends a notification email for each failed login attempt. Similar modules exists already in the module directory of ProcessWire. However, this module is designed to notify, even if specified user doesn't exist.
      Settings
      The settings for this module are located in the menu Modules=>Configure=>LoginFailNotifier.
      Notification email
      Specifies the email address to which the notification emails should be sent.
        Email subject
      Specifies the subject line for the notification email.
        Post variables
      Specifies the $_POST variables to be included in the notification email. Each variable must be separated by a comma. For example: login_name,login_pass
        Server variables
      Specifies the $_SERVER variables to be included in the notification email. Each variable must be separated by a comma. For example: REMOTE_ADDR,HTTP_USER_AGENT
      Link to ProcessWire module directory:
      https://processwire.com/modules/login-fail-notifier/
      Link to github.com:
      https://github.com/techcnet/LoginFailNotifier
    • By Fokke
      ProcessWire 3.x markup module for rendering meta tags in HTML document head section. Note that this module is not a full-blown SEO solution, but rather a simple tool for rendering meta tags based on module configuration. Adding custom meta tags is also supported.
      Built-in meta tags
      The following meta tags are supported out-of-the-box:
      Document title consisting of page title and site name Character set Canonical Viewport Description Keywords Hreflang tags Open Graph og:title og:site_name og:type og:url og:description og:image og:image:width og:image:height Twitter meta tags twitter:card twitter:site twitter:creator twitter:title twitter:description twitter:image Facebook meta tags fb:app_id The full documentation with configurable options can be found here: https://github.com/Fokke-/MarkupMetadata
       
      Requirements:
      ProcessWire>=3.0.0 PHP >=7.1 Installation using Composer
      composer require fokke/markup-metadata Manual installation
      Download latest version from https://github.com/Fokke-/MarkupMetadata/archive/master.zip Extract module files to site/modules/MarkupMetadata directory.
    • By m.sieber
      ITRK-Service for ProcessWire
      Module for the automated transfer of imprint, data protection declaration and terms and conditions from IT-Recht Kanzlei to your ProcessWire installation
      What is ITRK Service for ProcessWire?
      ITRK-Service for ProcessWire is a free module for ProcessWire CMS. It provides an interface to the update service of IT-Recht Kanzlei, via which the legal texts of your online presence are automatically updated. In this way, the texts remain legally secure and warning-proof in the long term. Imprint, data protection declaration, revocation and general terms and conditions are currently supported.
      You can find our documentation (in german language) here: https://www.pupit.de/itrk-service-for-processwire/dokumentation/

      Download: https://www.pupit.de/itrk-service-for-processwire/
      Github: https://github.com/pupit-de/pwItrkServiceConnector
×
×
  • Create New...