Form Submit Failure?

I am testing my website using ServBay on my Mac.

I installed and activated the Mailpit service.
The config is showing:

  • SMTP Port: 1025
  • Username: mailuser
  • Password:

I can open the Mailpit URL at https://mail.servbay.host

So I have setup a form:

  • Host: mail.servbay.host
  • Port: 1025
  • Username: mailuser
  • Password:

After I have published the website, I entered data into the form and clicked the button in the Submit Component. I then get the Error dropdown triggered.

How do I find out what is causing the error. Is there a log somewhere of why it failed? I can’t see anything in the PHP error log or Javascript console.

There is an internal logging system available, but I chose to not activate in the components shipped in Elements — my plan is to allow you to turn logging on and off, I’ve just had to prioritise other things these past few weeks.

I will add “Allow logging of form components” to my list, and try and get that one in sooner rather than later.

With regards to the issue — can you check that those credentials are correct? Can you send/receive email via another means with those credentials?

With the help of ChatGPT I ran this python script:

import smtplib
from email.message import EmailMessage

# Mailpit SMTP config
SMTP_SERVER = 'mail.servbay.host'
SMTP_PORT = 1025
SMTP_USERNAME = 'mailuser'
SMTP_PASSWORD = 'mailuserpassword'

# Email content
msg = EmailMessage()
msg['Subject'] = '✅ Test Email from Python (TLS)'
msg['From'] = 'sender@example.local'
msg['To'] = 'recipient@example.local'
msg.set_content('This email was sent using implicit TLS on port 1025 via Mailpit.')

try:
    with smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT) as server:
        server.login(SMTP_USERNAME, SMTP_PASSWORD)
        server.send_message(msg)
        print('✅ Email sent successfully.')
except Exception as e:
    print(f'❌ Failed to send email: {e}')

with this result:

✅ Email sent successfully.

Mailpit shows:

In Elements, my Form settings are:

When I click on the submit, nothing happens and nothing arrives at Mailpit.
I don’t get the Error or Success messages shown.

Not sure what to check out next. I have done all the ‘Mark Page as Changed’, closed and restarted Elements, republished and I can see the Form config.php file has been updated with the Form settings:

<?php

return [
    'component_id' => 'rwBD2AFA9F_87A3_47F3_B31E_838CD83D42B3',
    'spam' => [
        'service' => 'none',
        'recaptcha' => [
            'secret_key' => '',
            'site_key' => '',
        ],
        'turnstile' => [
            'secret_key' => '',
            'site_key' => '',
        ],
    ],
    
    'email' => [
        'host' => 'mail.servbay.host',
        'port' => '1025',
        'smtp_secure' => 'tls',
        'username' => 'mailuser',
        'password' => 'mailuserpassword',
        'subject' => 'Elements Contact Us',
        'to_name' => 'Elements Webmaster',
        'to_address' => 'info@servbay.host',
    ],
    
];

So unless there is something that leaps out as being wrong, I can wait until logging is introduced to help figure out why this isn’t working. :slightly_smiling_face:

on my form the username and the to address are the same

Changed the username and the to address to match but still the same result. It works OK being mismatched in the Python script, so I wouldn’t think they have to match?

I am getting this in the Mailpit log:

time="2025/06/04 14:22:03" level=info msg="[db] using tenant \"SBMP_\""
time="2025/06/04 14:22:03" level=info msg="[smtpd] enabling login authentication"
time="2025/06/04 14:22:03" level=info msg="[http] starting on 0.0.0.0:18025"
time="2025/06/04 14:22:03" level=info msg="[http] accessible via http://0.0.0.0:18025/"
time="2025/06/04 14:22:03" level=info msg="[smtpd] starting on 0.0.0.0:1025 (SSL/TLS required)"
time="2025/06/04 14:23:31" level=error msg="[websocket] websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header"

have you tried SSL rather than TLS?

I have now and it is working! Thanks. :folded_hands:

I changed the username and the to address to not match and it is still working OK.

I know there is a bug currently where the error message won’t be shown when authentication to the smtp server is rejected.

I can’t see anything else that could be an issue, so unfortunately you’ll have to wait for logging to be implemented — unless you feel comfortable editing the exported site yourself?

If so, you can go in and edit the /rw/elements/com.realmac.apipack/api/src/Classes/Email.php and use the logging class that’s available.

In that file you can do $this->logger->info("log me") to log a message to the app.log file, which can be found at /rw/elements/com.realmac.apipack/api/logs/app.log

1 Like

I am wondering actually if the issue is to do with the username and the to address.

I just noticed that the to_address is different in Elements to the one you have set in your python script

Python: recipient@example.local
Elements: info@servbay.local

have you tried with the exact same settings as the python script?

I said that…hahahaha

See this earlier post: Form Submit Failure? - #7 by logrunner

It is working now with different username and to address.

Yes, thanks but that wasn’t the issue. It was not selecting SSL.

That combined with the post from @ben “I know there is a bug currently where the error message won’t be shown when authentication to the smtp server is rejected.” was masking the issue.

So, in summary all appears to be good at the moment and if I get any further issues, I can mod the exported code to output the log. :slightly_smiling_face:

1 Like