View more context

 

Tim

Hi all, Can anyone suggest why my contact form emails arent sending? Doesnt seem to be producing any errors and I can see the form data in the header on the redirect but doesn't seem to be sending any emails. Cheers in advance

Tim

I'm able to send emails using a very similar function on other pages so I dont think Its my email set up thats broken.. but maybe I've missed something

Lorrain Fontaine

I personally can't really tell, did you try giving your $form variable a name? (the 2nd parameter, on line 17)

wilr

@Tim what’s the var_dump of $email->send(); should be 1.

Tim

@wilr sorry how do I check that - silverstripe isnt my usual CMS

Tim

@Lorrain Fontaine that second parameter seems to set the redirect, as I wanted it to redirect back to the homepage, I've left that blank on purpose

wilr

var_dump($email->send()); die(); you should see a 1 if the email sent

Tim

@wilr forgive my uselessness but which line would I insert that on? and where would I expect to see the 1? in the console?

wilr

Replace the email->send() with that line. You’ll see it in the web browser

Lorrain Fontaine

(Just insert it before the try catch.) You're trying to send your e-mails locally? It usually fails to send locally for me unless I use a mailcatcher which I almost never do unless I have really complex forms 🙂 .

Tim

Cant see anything unfortunately, just redirects back to home and nothing happens - tried it in both places suggested above. I'm trying this locally but could push to a staging site if that might be the issue?

wilr

perhaps a syntax error before it gets to the send. Have you tried linting the code?

jkersu

Did you run a dev/build flush after adding the allowed actions?

Lorrain Fontaine

I personnaly still believe you need to give the form a name 😛 if it acts on the redirect, that's not a real problem.. Try giving it the name "Form" (the name of your public function). Because if the var_dump doesn't work, it either means the error is before that var_dump, or you redirect to the homepage instead of the current page. Anyway you could submit your form, then redirect it to the home page

$this->redirect('/'); (haven't tried this one)

with a message saved in session :

$request = Injector::inst()->get(HTTPRequest::class); $session = $request->getSession(); $session->set('successMail', true);

And check if that value exists on your home page

Lorrain Fontaine

As you can see, PHPStorm typehints the 2nd parameter as the "name" of the form, that's why I call that the name. I don't know if it has anything to do with the redirection tho. Is that the only thing that changed compared with your other forms ?

wilr

Yeah 2nd name parameter needs to be ‘Form’ in your case - it’s the name of the method on the controller

Tim

You guys rock. Sorry for my slow response, I ducked out for a surf. So I added Form as the name and now the email is sending! Previously I had named it everything other than form and that didnt work.. But now I'm getting the emails and returning bool(true) as a result of the var_dump so thats epic. Thanks heaps!! really appreciate it!

👍 (1)

Show less replies
Conan

Is 4.4 SS framework not compatible with PHP 7.3?

  1. [Deprecated] stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
  2. GET /
  3.  
  4. Line 274 in /app/vendor/silverstripe/framework/src/Core/Manifest/ModuleManifest.php

stripos() got deprecated in php 7.3.0

kinglozzer

ISTR seeing a Github issue about deprecations…

kinglozzer

https://github.com/silverstripe/silverstripe-framework/issues/9180

Show 1 attachment(s)
GitHub  
Deprecated message on page load · Issue #9180 · silverstripe/silverstripe-framework

Affected Version silverstripe/framework 4.3.1 , also appears in 4.4 codebase php 7.3.1 Description Loading any page that uses the translation function in a controller will cause a deprecation messa...

Hide attachment content
kinglozzer

error_reporting(E_ALL & ~E_DEPRECATED); is a possible workaround for now

✔️ (1)
phyzical

hey gang, have a website that was running silverstripe 4.x and upgraded to 4.4

phyzical
  1. SilverStripe\Core\Injector\InjectorNotFoundException
  2.  
  3. ReflectionException: Class Psr\SimpleCache\CacheInterface.ThemeResourceLoader does not exist in
phyzical

any idea how to narrw his down teh trace seems to stay within the framewokr is it possible ive just updated things incorrectly depency wise, had a look at the change log couldnt see anyhting obvious