Struggling with Plone mail setup (it's asking me to run connect())

I have a Plone 5 site set up and working great. However, I can't get mail to work. I'm currently using SMTP server: on port 25. When I click "Save and send test e-mail" it says " Error Unable to send test e-mail please run connect() first."

I have another site set up on Plone 4 with the exact same SMTP server configuration, and it works. So I'm not sure what's going on. Any ideas? Is there anything special I have to do to set up Plone mail on the server end?

I have more info, from the log file:

2023-03-02 15:31:46,955 ERROR   [Plone:88][waitress-1] Unable to send test e-mail.
Traceback (most recent call last):
  File "/opt/plone/buildout-cache/eggs/zope.sendmail-5.1-py3.8.egg/zope/sendmail/", line 115, in send
    connection.sendmail(fromaddr, toaddrs, message)
  File "/usr/lib/python3.8/", line 901, in sendmail
    raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (550, b'5.7.1 [] Messages missing a valid messageId header are not\n5.7.1 accepted. c126-20020ae9ed84000000b0074271e0c985si12214380qkg.189 - gsmtp')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/plone/buildout-cache/eggs/Products.CMFPlone-5.2.2-py3.8.egg/Products/CMFPlone/controlpanel/browser/", line 79, in handle_test_action
  File "/opt/plone/buildout-cache/eggs/Products.MailHost-4.9-py3.8.egg/Products/MailHost/", line 213, in send
    self._send(mfrom, mto, messageText, immediate)
  File "/opt/plone/buildout-cache/eggs/Products.MailHost-4.9-py3.8.egg/Products/MailHost/", line 320, in _send
    self._makeMailer().send(mfrom, mto, messageText)
  File "/opt/plone/buildout-cache/eggs/zope.sendmail-5.1-py3.8.egg/zope/sendmail/", line 117, in send
  File "/opt/plone/buildout-cache/eggs/zope.sendmail-5.1-py3.8.egg/zope/sendmail/", line 75, in _close_connection
  File "/usr/lib/python3.8/", line 997, in quit
    res = self.docmd("quit")
  File "/usr/lib/python3.8/", line 424, in docmd
    self.putcmd(cmd, args)
  File "/usr/lib/python3.8/", line 371, in putcmd
  File "/usr/lib/python3.8/", line 363, in send
    raise SMTPServerDisconnected('please run connect() first')
smtplib.SMTPServerDisconnected: please run connect() first

It seems like Plone's test email is not including a messageid header? I'm not sure how to fix this. Anyone have any ideas?

I haven't heard of a messageid header before. It sounds like some requirement that GMail is enforcing in order to accept mail.

This thread makes me think that it might help to ensure that the domain that the email is being sent from has an SPF record which allows relaying mail from the Plone site's IP address. Message could not be delivered due to Missing valid MessageID Header - Gmail Community