I needed a way to collect email addresses for a royalty free music site that I own.
I use sendy for email and after a little experimenting, got this working perfect. It's not hard, but it is a little counter-intuitive, at least for me.


Okay, everybody. This is Jon Griffin. I'm gonna show you one thing that I found out with the Drupal 8 Webforms module.
One thing I wanted to do was have some separate forms that actually go to different lists under my main list. In this case I give away some free royalty-free music and I didn't want that in my general list. I wanted them to be on a separate list.

So in order to get the packet they have to basically put in their first name and their email. Then they get sent to my list with an email back giving them a page to download all that.

I'm not gonna show you how to install Webforms or the basics of it or anything else; there's plenty of tutorials, including what's included with this plugin, which is a great plugin. Beats anything I've seen in WordPress, especially for the price, which is free.

So basically what I want to do is show you in build ... You can see I've got a text field. The email ... I put a CAPTCHA in, of course. And "list" is a hidden field but it's gonna have the actual list that's in my sendy, because this is all related to sendy, which I should have mentioned at the beginning but I forgot. Anyway, so sendy.co is who I use, because I own my data and it's a lot cheaper than anywhere else.

Forgot to put required, so I can fix that. So we're gonna save that. And so basically that sets your form. You can take a view, which you can see here shows that now it's got the email as required.

But the important thing is when hooking it up to sendy is you want to have email handlers. So basically right now when this form gets submitted it goes to this completed URL, and I also send the actual list, which you'll see here. So you'll see what I did. I send the email and I send the actual list as parameters to this URL, slash subscribe, which happens to be my sendy installation. Of course it'll add the question mark and all the URL variables.

That's really all you have to do. It's quite simple. If you don't know how to get the email list out of sendy you basically go to your subscriber list ... and I have only one list far, and I just started it so there's no people. But royalty-free ... and if you go right here, this ID, which you can just copy ... So that's the actual ID that you'll put in when you build. And you'll see when I have a hidden field that the default value's there. Nobody's gonna see it to change it. Really this isn't any high-security thing so whatever standard will work.

So that's all you need to do. Of course, I've blocked out some numbers because there are scammers and spammers about. But hopefully that'll help you out.

And when you're done you can always test it. The nice thing is it'll put up some random name and a random email. Unfortunately sendy will block it as spam so you gotta add some name in there and then hit submit, and you can go to your sendy installation and show it. So basically if you go to "Edit remote post handler" to "Advanced" you can set up the debug mode. And I use that—I don't need it now—just to see what I was sending. So you can actually see if I do a test, which as I said with the fake email address it won't probably take it on sendy because of the spam filtering built into it, but we'll hit it just so you can get an idea. If you just click on this you see what the form parameters are, where it was sent, and it actually gives you the response data which says, "You're subscribed." So in that case it did take it. So the tokens can be used if you want.

There's a lot more to this but that's all you really need. It's a simple thing.

And I hope that helps everybody out. If you have any questions please leave a comment.

Submitted by tresero on Fri, 12/18/2020 - 19:08