SendEmail with Time

I am trying to send an email that includes the time. It seems that if the message field includes a colon the message field in the email will be blank.
If I do:

The following will show the correct text in the message field:
But if I use the following, no text will show in the message:

In fact
strftime(“%b %d %-I " + “/”+” %-M %p")
will have the message, Feb 11 8 / 48 PM
strftime(“%b %d %-I " + “:”+” %-M %p")
will have a blank message
The only difference being a “:” instead of “/”

I’m not sure what your sendEmail() is doing but the all appear to work fine on my WSL:

In [5]: now.strftime('%b %d %-I / %-M %p')
Out[5]: 'Feb 11 8 / 6 PM'

In [6]: now.strftime('%b %d %-I : %-M %p')
Out[6]: 'Feb 11 8 : 6 PM'

In [7]: now.strftime('%c')
Out[7]: 'Sat Feb 11 20:06:23 2023'

In [8]: now.strftime('%X')
Out[8]: '20:06:23'

I’m guessing the issue is with sendEmail()

I agree but why does a colon create such a problem?

You would need to provide the implementation details for sendEmail() for us to be able to try to see.

These are the imports

import sys
import pigpio
import _433
import paho.mqtt.client as mqtt
from operator import itemgetter
import time, socket
from datetime import datetime, timedelta
import smtplib

Here is the function: ( is a dummy for my real account)

def sendEmail(recipient,subject,message):   
    s = smtplib.SMTP('', 587)
    s.login("", "blanked out")
    s.sendmail("", recipient, f"Subject: {subject}\n{message}")

Results of some more testing:
If the message is just, “some text” it will be received.
If the message is, “some text”+“:”
(That is a colon in the +“:”)
The received message field will be blank
If the message is, “some text+”;"
(That is a semicolon in the +“;”)
All the characters will be in the received message field

Now for the kicker. I am using the exact same code in another script and it works fine.

Odd. The only thing i can think of is maybe some encoding messes with it?

Try this:

import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

    with smtplib.SMTP('', port=587) as smtp:
        smtp.login(<user>, <password>)

        msg_mime = MIMEMultipart("alternative")
        msg_mime["Subject"] = <subject>
        msg_mime["From"] = <sender>
        msg_mime["To"] = <to>
        msg_mime.attach(MIMEText(<msg content>, "plain"))

        return smtp.sendmail(sender, [to], msg_mime.as_string())

Hopefully it works… otherwise I’m out of ideas.