taers232c / GAMADV-XTD3

Command line tool to manage Google Workspace
732 stars 86 forks source link

Failing to modify the content-type header in "insert message" command #114

Closed Aldekein closed 3 years ago

Aldekein commented 3 years ago

GAM version

GAMADV-XTD3 5.31.01 Python 3.9.1 64-bit final google-api-python-client 1.9.3 httplib2 0.18.1 MacOS Catalina 10.15.7 x86_64

Steps To Reproduce

gam user aldekein@aldeke.in insert message labels INBOX,UNREAD,IMPORTANT content-type "text/html; charset=\"utf-8\"" subject "This fails" htmlfile "data/training.html"

will print an error:

  File "gam.py", line 50612, in ProcessGAMCommand
  File "gam.py", line 47437, in insertMessage
  File "gam.py", line 47381, in _draftImportInsertMessage
  File "gam.py", line 47253, in _appendToHeader
AttributeError: 'str' object has no attribute 'append'

Expected Result

A new email is inserted in the user's mailbox with the specified content-type header.

Additional info

If the command is changed to insert another valid header listed in GamCommands.txt values for <SMTPHeader> (e.g. keywords) it will work and the header is added to email:

gam user aldekein@aldeke.in insert message labels INBOX,UNREAD,IMPORTANT keywords "text/html; charset=\"utf-8\"" subject "This fails" htmlfile "data/training.html"

taers232c commented 3 years ago

The Python library is handling content-type differently than other headers; it is usually derived by the received mail system. If you omit from the command, what do you get?

Ross

Aldekein commented 3 years ago

If I'm not specifying content-type or specifying another header declared in SMTPHeader GAM works correctly.

taers232c commented 3 years ago

Oleh,

Good to hear. The problem was content-type, it can't be explicitly declared, the API sets it to the appropriate values.

Ross

On Thu, Jan 7, 2021 at 9:51 AM Oleh Aldekein notifications@github.com wrote:

If I'm not specifying content-type or specifying another header declared in SMTPHeader GAM works correctly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/114#issuecomment-756274521, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYLY6IG5SOIJCP2OZE2TSYXYAXANCNFSM4VXRCAUQ .

-- Ross Scroggs ross.scroggs@gmail.com

Aldekein commented 3 years ago

Ok, thank you for confirmation. I supposed if it's listed in documentation it should work :)