New form component

@ben Fought with this for years with a stack.

$headers = "From: " . $email . "\r\n"; // this would need to be changed to an address tied to the domain noreply@host.com
	$headers .= "Reply-To: " . $email . "\r\n"; // this can be as is, the senders address.

ChatGPT explains far better than I ever could. There are a lot more details but the crux of it is some hosts have this security in place some don’t.

3. SMTP Configuration

If you’re using SMTP to send emails (which is likely the case in a production environment), the SMTP server may require that the sender’s email address matches the domain used in the SMTP credentials (username and password). If the sender email doesn’t match, the SMTP server may reject the request, resulting in the form submission failure.

its not rejecting it…and I have a form in foundry works perfectly
as in whatever email I put in the FROM field is exactly what shows in the email…not my own. if someone uses the form they should be putting their email in not mine.if I hit reply it would come straight back to me!!!

IIRC the code should already be setting the from and reply-to headers correctly - but there obviously a bug somewhere :sweat_smile:

We can set a “From” address, and a separate “Reply To” address - this means that when you hit reply, the reply will be sent to the “Reply To” address.

The Form component just needs to ensure both the “From” and “Reply To” addresses are set correctly.

We will get this all fixed up and working correctly in the coming beta or two :slight_smile:

Un-tested, but may work, as it would be nice to have the from header as well as the reply-to header be the senders address where possible (server pending).

<?php
$fromEmail = $email; // The email entered by the form filler
$hostDomain = "yourdomain.com"; // The domain associated with your server

// Extract the domain from the email address
$emailDomain = substr(strrchr($fromEmail, "@"), 1);

// Check SPF record for the domain
if (checkdnsrr($emailDomain, 'TXT')) {
    // If SPF record exists for the domain, proceed with sending the email
    $headers = "From: " . $fromEmail . "\r\n";
} else {
    // If no SPF record exists or domain is unauthorized, use your own "From" address
    $headers = "From: noreply@yourdomain.com\r\n";
}
?>

That’s never going to work :index_pointing_up:
Safer just to guarantee the norepy@

<?php
$headers = "From: noreply@yourdomain.com\r\n"; // Always use a trusted address
$headers .= "Reply-To: " . $email . "\r\n"; // Allow the form filler’s email as the Reply-To address
?>

wooooshhhhh that was the sound of code going over my head

Just checked the code—and it turns out the From address is being set to the email field from the form. That explains why it fails when using anything other than an email address from the same domain!

This one will be fixed in the next beta :slight_smile:

So, was the form component fixed in the last beta (maybe 2 days ago?)…or is it still a work in progress?

I’ve been banging my head on the wall trying to get this thing to work (in the “Fitness” project sample, published to a sandbox site on my host.

I’ve tried multiple variations of configurations to no avail! I’ve also used “mail”, “smtp”, etc. in front of the host address too.

Yes, I’m trying to send to a different e-mail (which I read was now possible), but I have also tried using the email directly associated with the form and host. It still gave me my “Oops! Something went wrong!” message.

I’ve updated my PHP version to 8.4. The recommended API test does not work (I don’t see any message when I append “?apicheck” to the page.

Here’s what I’ve been working with (see screenshots of the settings section and my host’s config details - yes, password was filled in my form settings, just left it blank for the screenshot for this post).

What am I doing wrong?

Thanks!

works fine…dont know anything about sandboxes tho I just used my server settings and all good.

The fact that this is not working might suggest that the form (and the required files) have not been published correctly. Can you try “re-publishing all files” and see if that resolves the issue.

@dan , I’ve re-published all files numerous times…even gone in manually and cleared out everything in CPanel, the re-published again…no joy :frowning: This apicheck still does not display.

I’ll admit, I’m no coder or web expert, but I’ve managed to get this stuff working on numerous occasions with earlier versions of RW. This has me stumped.

I may also reach out to my host today and see if there’s anything going on server-side.

EDIT: Working with my web host right to to check for any issues.
I’ve also tested to ensure outgoing messages can send from the address I’m using in the form.

on the top image my server has a different port number for TLS
465 on my server is for SSL dont know if that makes a difference or not

Thanks @Godber …it wasn’t that, BUT…I got it solved!

A few things were at play to get this to work:

I needed to change my host address. Was given something different from what I was expecting from my hosting company’s support team.

Initially, even the new host info did not work. And I found it a little strange that the RW Elements “Fitness” project was only publishing 77 files.

@dan Can you take a look at the Fitness project ?

I copied my form and pasted JUST the form into a new blank project - it then published almost 800 files!. And on the first try in the empty project, boom! It worked.

Now, the only thing that’s still a bit wonky is that the email I got from the form looks like this:

Hope this helps!

yeah I had this in one of my forms
Radio-rw3FACF85D 87AD 4ACF B70D 4745E175D6FE: Yes
Dan solved it by telling me to give the form item a name.
and it worked fine
in the settings

Thanks David. I hadn’t seen that feedback.

Added names to all input fields and all now works as expected!

Also, copied the new form with named fields BACK into the “Fitness” project, republished all files, and now it seems to work.

Feels like a win to me! :wink:

And thanks @dan for being so responsive and transparent throughout this process! I’m excited to see what comes next!

Cheers!

Just an FYI to anyone reading this: we had to give each field a unique name by default, this is why you’ll see something like input-{UNIQUE-STRING-ID} when you have manually entered a name for the field.

Just enter a name for the form input in Elements and everything will update automatically :slight_smile:

Glad to hear everything is now working for you :star_struck:

I am struggling with the Form component in Elements also.
Gave the various parts a name. The Form itself. Put in “all” fields. Reset is strange though. No matter if I have that on or off, it not showing in the published page.
Tried on my server, tried with ServBay (nice, thanks for the tip!).
Verification of required fields runs (fine) when clicking on “Submit”, but that seems to be it.
Any ideas? Pointers? as what to look at next …?

Ohh, this is with Elements 0.8.2 (53544) by now …

do you have a live URL we could take a look at?

I am wondering if there are any errors in the developer console in the browser!

Hey Ben,
thanks for speedy response! Much appreciated :smiley:

Yes, I can put it “out there” . Please do check out this URL if you have the time.

I guess what I am struggling with is this message (from Safari Console log):

Failed to load resource: the server responded with a status of 404 ()

https://www.vps13.org/rw/elements/com.realmac.apipack/api/email

Please note that I tried deleting all files manually, Re-Plublishing “All” and noticed that File➜ “Publish Current Page …” still publishes 685 files after a Publish All.
Lot’s of them .php files …
The message above comes after doing this.

Looking forward to your, as always, educating feedback.

Hi Ben is there a way to send my project to be looked at. I’m having trouble getting the form to submit. Thanks!