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?
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?
(Also considering 3rd party solutions, but currently mostly trying to figure out how Blocs itself works/what it allows for.)
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.
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) …
I guess I’ll figure it out, but it’s been a while since I created forms in PHP manually …
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 … (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 … 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 … (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)?
(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
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.
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?
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 firstname.lastname@example.org? 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.