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
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
I personally can't really tell, did you try giving your $form variable a name? (the 2nd parameter, on line 17)
@Tim what’s the var_dump of $email->send(); should be 1.
@wilr sorry how do I check that - silverstripe isnt my usual CMS
@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
var_dump($email->send()); die(); you should see a 1 if the email sent
@wilr forgive my uselessness but which line would I insert that on? and where would I expect to see the 1? in the console?
Replace the email->send() with that line. You’ll see it in the web browser
(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 🙂 .
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?
perhaps a syntax error before it gets to the send. Have you tried linting the code?
Did you run a dev/build flush after adding the allowed actions?
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
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 ?
Yeah 2nd name parameter needs to be ‘Form’ in your case - it’s the name of the method on the controller
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!
Is 4.4 SS framework not compatible with PHP 7.3?
- GET /
- Line 274 in /app/vendor/silverstripe/framework/src/Core/Manifest/ModuleManifest.php
stripos() got deprecated in php 7.3.0
ISTR seeing a Github issue about deprecations…
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
error_reporting(E_ALL & ~E_DEPRECATED); is a possible workaround for now
It does run fine on 7.3 aside from that
hey gang, have a website that was running silverstripe 4.x and upgraded to 4.4
- ReflectionException: Class Psr\SimpleCache\CacheInterface.ThemeResourceLoader does not exist in
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