Blocs 4 form SMTP setup

If I understood correctly, the default forms in Blocs use phpmailer. If I want to send using SMTP, I need to replace/insert some custom code (a PHP SMTP mailer or something, I guess).
What’s the best/most robust way to do this?
Read an old topic here, which included some .zip file and instructions to replace code on the uploaded files.

How to best do this without loosing custom code every time I upload revised project export from Blocs? :thinking: :nerd_face:
Place my script in a separate folder/folder which does not have contents replaced, and then somehow link to/use my script inside Blocs? Or would I have to run a sed operation on every export/upload? :sweat_smile:

(Also considering 3rd party solutions, but currently mostly trying to figure out how Blocs itself works/what it allows for.) :smiley:

1 Like

I think this will be included at some point in time by @Norm in the standard.


have you tried:

1 Like

Looking forward to that point in time! :sweat_smile::pray:

Looks cool, anyone implemented this in their Blocs design? :sweat_smile:

Just had a quick look but a the moment you can only use their (paid) elastic email SMTP/API.

If you attach the index.js, use password hash and scramble the file with an obfuscator. You should be good, I think, maybe? :thinking:. Any ideas on this @Jannis?

I currently use a third-party solution on most of my client websites. This option allows you to create several more advanced contact forms through a simple user interface on your server and then embed a small piece of generated code into your blocs website project which displays your form in the webpage. The script can be configured for either php-mailer or SMTP. It also has a few other options such as file uploads. The admin area of the script gives you a full management facility where you can see all your responses and email attachments/uploads. If you buy a developer licence for the script - €27, you will be able to use it on multiple websites. Alternatively, you can buy a single domain licence for about €17 and have it set up on a single server where you can create multiple forms for use on several websites.

1 Like

I always hesitate with authentication data inside JavaScript or HTML files :sweat_smile:


If I want to use a different script to send, rather than the provided form_id.php in includes, I select Custom, and I need to figure out the custom-action-url to use my own script (based on PHPMailer or whatever) … :smiley: :thinking:
I guess I’ll figure it out, but it’s been a while since I created forms in PHP manually … :sweat_smile:

1 Like

In particular considering using something like this:

Instead of replacing the default created form script, it should be possible somehow to just select Custom instead of Self Hosted and offer a custom action url that utilizes this script in the Action field … :thinking: (The referenced zip file seems to contain the required PHPMailer files.) … But I havent’t been able to quite figure out the required custom-action-url yet … :sweat_smile: If I use a copy of the original script created by Blocs, just give that as the action url, it works in the way that it sends the email, but I end up in a blank page. So I guess there’s some js magic happening in the default/self-hosted setup, that Custom does not replicate … :exploding_head: :nerd_face: (I need a break now, will look more later.)

Edit: I was able to make my own PHPMailer script that successfully sends the email. But with the default Blocs script, one get a nice added Success/Failure message. With the Custom script, I end up at my script and whatever output I add to that.
Would it be difficult to pull in/return the JS or whatever the default script uses? (@Norm ?)
(If I just leave it at Self Hosted and replace the script generated by Blocs with my own, email is sent by SMTP, and it behaves as before, but if I invoke my script using Custom action, I get a blank white page.)

So … nobody can tell how to use Custom instead of Self Hosted and still get the fancy inline confirmation notice (JS or Ajax or whatever it is)? :sweat_smile:
(The actual PHPmailer script I made works, and if I leave it at Self Hosted and then replace the Blocs generated script with mine, it works like a charm, but I have to replace after every export/upload …)


The only thing that bothers me about Blocs is that you can’t create an SMTP form. Unfortunately, all the forms I’ve created in Blocs so far don’t work. I now create my forms in WebAcappella (SMTP) and insert them into blocs with iframe. unfortunately very sad :frowning:

I find it perplexing when some have difficulty with forms in Blocs, because I’ve never had one that didn’t work and its really easy if you just use Blocs own self hosted solution. Just adding a to address and a from address is not exactly complicated, so I have to wonder if those having problems need to look at their hosting set up.


Curious… why is it so important for Blocs to incorporate SMTP forms?

One problem might that some hosts don’t handle PHP mail scripts well. It happened to one client of mine. Fortunately for me I am his new host now…

Disregarding the php/smtp setup (the host should be jumping through hoops to keep you and not the other way around in my opinion, and offer both ways), I’ve never encountered any problems with the inbuilt Blocs forms.
If someone as simple as me can do it, then I’m sure others must be overthinking it somehow.

There’s many reasons why SMTP is recommended for most setups. The main being that just using mail() in PHP utilized the shared host setup, which often uses a shared IP, so one bad neighbour results in your email being dropped as spam due to IP reputation. (So: Reliability and deliverability. I’ve seen many such issues, and also many that didn’t know they had issues, as the bounces never reached them.)
The other main reason might be volume. Some web hosts include 50-100 email per day. If you need more traffic, you need a better setup.
My main reason is that I want a setup that sends using my high-reputation SMTP service, and that will keep on working, even when/if I move the site from one web host to another. (Without then having to change/fix SPF, DKIM, DMARC etc.)

So … I didn’t really want to debate SMTP why or why not, but how to actually get it up and running. Back to the topic:
Does anyone know how to implement/include the fancy JS/AJAX (or what it is) from Blocs’ default mail script into a Custom script?

1 Like

Just a suggestion, you could use the Tectite Formmail Script with your blocs created forms. To make the forms work you will have to add a couple of hidden fields to your forms and then send them to the script which you host on your server. There are setting within the script for setting up SMTP as an alternative to the standard PHP mail. Full information on how to configure the script is available on their website. The script is free, but for a small fee, they will configure it for you.

Thanks for the numerous replies, I have discussed the problem with my provider before, when submitting a form, no script is triggered to send the form. Not being a programmer, it would take me days or weeks to write, rebuild or include a PHP script. To make it work I would prefer a simple and simp,e SMPT solution. Basically, I manage to create a self-hosted form using Block. Sometimes the script triggered sometimes not (e.g. after an update of the website nothing works anymore).

Dumb question perhaps but I am assuming you have set up the email address where you want to receive email and verified that it works with your email client? Also is your from email address the same as your domain e.g You cannot send from gmail for example.

If you want, send me a PM with your email address and I’ll throw up a quick test page on a spare domain with a contact form so we can see if you receive the email.

Thanks for your help, I once created a form in blocks (photo). And uploaded to the homepage: pv
Unfortunately, when I fill out the form and send it, nothing arrives at my e-mail address. :frowning: