Python Mailbox Problem

I updated my laptop to Mac Os 14.3.1. I installed Python 3. The configuration/instruction page in the database exchange is missing. When I run my procedure I get this error message " /usr/bin/python (not installed)". When I look in /usr/bin/ I see python3. How do I solve this?

Thanks Bill

You probably haven’t configured the Panorama Preferences for Python 3.

See Scripting Language Configuration

1 Like

Thank you for your help.
It feels like “If you give a mouse a cookie” I’ve installed python3, its toolbox, Homebrew, its config pkg., Xcode. I don’t know what’s next but I’m sure there is something.

Sorry to bother you again but…
When I test Mailbox I get:

PYTHON ERROR: File “/var/folders/1b/f4g9t4p08xj7vq0059blv3q00000gq/T/pan.2024.02.29.15.01.23.950.py”, line 14

‘’’

^

IndentationError: expected an indented block

Panorama reports a "Sending Error: me@xyz.com (email recipient) ".

I held down the option key and clicked “About Mailbox” and this message appeared:

Python: 3.9.6 (default, Dec 7 2023, 05:42:47)

[Clang 15.0.0 (clang-1500.1.0.2.5)]

The code in my procedure to send email is: FarCall “MailboxHS”,“.SendMail”,“calendar entry”

Thanks for any help you can give me,
Bill

No bother. It’s important to me that this all works ‘as advertised’.

Python Is very picky about indentation. Staring any line with the wrong number of spaces will cause the type of error you’re encountering. But line 14 is truly a surprise unless you’ve done some editing to the procedure; no accusations intended.

If you’re literally sending to mailto:me@xyz.com, that’s certainly going to cause a sending error, but that’s different than the spacing error and an indication that the procedure ran fully. That conflicts with the spacing error.

Mailbox shows a version number. What is yours showing?

Also, the Python error includes a path to a temporary file Panorama creates to send the message. Opened in an app like BBEdit, it shows exactly what line 14 look like. You’re welcome to share that file but be sure to replace your email address, server, and password info with some nonsense to protect yourself…

Should I send those files to your .biz address?
Thanks,
Bill

I think he was suggesting that you open the file in BBEdit (or a similar editor) and then post the contents here on the forum, being careful to redact your personal info.

Mailbox v 3.5.
I’m not being allowed to upload the .py file from Bbedit or the copy of Mailbox. Am I missing an attachment button ?
Bill

You can copy the text in BBEdit ( or whatever text app you’re viewing it in ) then paste it here. Ideally you then highlight it and click on the Pre-formatted text button above to format it properly.

Screenshot 2024-03-04 at 6.16.53 AM

Line 14 is: “” . If this is the problem I imagine it’s going to happen a lot in this script. It looks like everywhere an email address goes it does this.
Thanks for looking at this.
Bill

#!/usr/bin/python3

import ssl
import smtplib
import mimetypes
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.base import MIMEBase
from email import encoders

try:
    #strTo = '''prog@hsoul.org
'''
    strTo = '''prog@hsoul.org
'''
    strFrom = '''H & Soul <prog@hsoul.org
>'''
    strCC = ""
    strError = ""
    strImages = ""

    msg = MIMEMultipart('related')
    msg['Subject'] = '''Python Email'''
    msg['From'] = '''H & Soul <prog@hsoul.org
>'''
    msg['Reply-to'] = '''prog@hsoul.org
'''
    msg['To'] = strTo
    msg.preamble = 'This is a multi-part message in MIME format.'
    
    # Encapsulate the plain and HTML versions of the message body in an
    # 'alternative' part, so email agents can decide which they want to display.
    msgAlternative = MIMEMultipart('alternative')
    msg.attach(msgAlternative)
    msgText = MIMEText('''An Email Settings Test prog@hsoul.org
 @ 4:32 pmSent via smtp.gmail.com to prog@hsoul.org

''')
    msgAlternative.attach(msgText)
    msgText = MIMEText('''<p>An Email Settings Test prog@hsoul.org<br /> @ 4:32 pmSent via smtp.gmail.com to prog@hsoul.org</p><p></p>''', 'html')
    msgAlternative.attach(msgText)

    # Attach Any Images
    images = ''''''.splitlines()
    i=1
    for image in images:
        # print 'Image',i,': ',image,'\n'
        fp = open(image, 'rb')
        msgImage = MIMEImage(fp.read())
        fp.close()
        # Define the image's ID as referenced above
        msgImage.add_header('Content-ID', '<image'+str(i)+'>')
        msg.attach(msgImage)
        i+=1

    # Attach any files
    files = ''''''.splitlines()
    for file in files:
        attachment = open(file, "rb")
        part = MIMEBase("application", "octet-stream")
        part.set_payload((attachment).read())
        encoders.encode_base64(part)
        part.add_header("Content-Disposition", f"attachment; filename= {file.split('/')[-1].replace(' ','%20')}")
        msg.attach(part)     
                             
    #send the email
    smtp = smtplib.SMTP('''smtp.gmail.com''', '''587''') 
    smtp.ehlo() 
    smtp.starttls()
    smtp.login('''ZZZZZ
''', '''XXXXX''')
    smtp.sendmail(strFrom, strTo.split(","), msg.as_string())
    smtp.quit()
except: print("Sending Error : "+strTo)

The fact that the quotes carry over to the next line after every occurrence of your email address suggests that you have a Return entered with it.

I’ll add a filter to disallow it in the future but removing that in the Mailbox setup should make all the difference.

“but removing that in the Mailbox setup should make all the difference.”
Sorry for the hand holding but how do I do that in Mailbox setup?

When you set up your account in the Mailbox Settings, you apparently added a Return after your email address - maybe you pasted it from elsewhere.

Based on what you shared, there should be nothing following the .org in your email address.

I did copy/paste originally but I just went thru and deleted any space and the last letter and then retyped it for every entry. I’m still getting the same error.
Bill

Since it looks like you didn’t follow Jim’s suggestion to redact this information, your gmail login information is now public on the interenet. So I would suggest that you change that ASAP, if not sooner!

I have to agree with Jim Cook, it appears that you have an extra carriage return at the end of the Sender Email Address, the UserName and the Reply to Address. I would completely delete all three of these (click in each field and press Command-A) and then manually type in each of these fields.

Ouch! I never got past the obvious returns at the beginning and didn’t notice the failure to otherwise de-personalize the critical parts. I was able to edit them, but yes, they’ve now been hung out publicly and should be changed.

You may not see the fact that a Return is included if you click at the end of the email address since it amounts to a new line. Retype it or use the right arrow key to move the cursor to the right and beyond the ending “g”. It’ll undoubtedly disappear after pong by the Return. Then the backspace key should allow you to back it up to the point where the g is absolutely the end.

The info in the Sender/Server/return is nonsense. It is not anyones info I know. I’m going to download a new Mailbox and start over.
Thanks for your help,
Bill