Giter Club home page Giter Club logo

gmail-sender's People

Contributors

kami avatar paulc avatar tanmayb123 avatar theonewolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gmail-sender's Issues

Not finding GMail

Hi, I installed the gmail package via pip install gmail.

The CLI for this works, however when I go to run the basic commands
import gmail

gmail = GMail('A.User[email protected]','')
msg = Message('Test Message',to='[email protected]',text='Test')
gmail.send(msg)

I get an error message stating that 'GMail' is not found. I went to the command line using python3 and it pulled up

when I do

import gmail
it recognizes gmail, I tested this by doing
xyz
and got an error message.

However when I used the GMail(), Message() or Send() it gives me an error saying it is not defined. When I put the import gmail in my IDE (VSCode) it states that it's an unresolved import.

I went back and hit pip3 install gmail just to be certain and it said the requirement is already fulfilled.

Thanks!

`gmail.send` exception handling broken in Python 3

Tried sending an email with this snippet:

gmail = GMail('Me <[email protected]>', 'password')
msg = Message('Test Message', to='Me <[email protected]>', text='Hello')
gmail.send(msg)

Delivery failed but an error with <bytes>.startswith masks the actual exception. This is the traceback that comes up:

Traceback (most recent call last):
  File "./send_email.py", line 8, in <module>
    gmail.send(msg)
  File "/path/to/project/lib/python3.4/site-packages/gmail/gmail.py", line 91, in send
    self.connect()
  File "/path/to/project/lib/python3.4/site-packages/gmail/gmail.py", line 76, in connect
    if e.smtp_error.startswith("5.7.14"):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Getting Exception on `__del__` Method Invocation

Basically object cleanup is having this exception:

Exception ignored in: <bound method GMail.__del__ of <gmail.gmail.GMail object at 0x7fc08e2c1fd0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/gmail/gmail.py", line 137, in __del__
    self.close()
  File "/usr/local/lib/python3.5/dist-packages/gmail/gmail.py", line 130, in close
    self.session.quit()
  File "/usr/lib/python3.5/smtplib.py", line 978, in quit
    res = self.docmd("quit")
  File "/usr/lib/python3.5/smtplib.py", line 419, in docmd
    self.putcmd(cmd, args)
  File "/usr/lib/python3.5/smtplib.py", line 366, in putcmd
    self.send(str)
  File "/usr/lib/python3.5/smtplib.py", line 356, in send
    raise SMTPServerDisconnected('Server not connected')
smtplib.SMTPServerDisconnected: Server not connected

The code snippet is fairly simple:

...
msg = Message('Something', to=recipients)
...
GMail(user, password).send(msg)

The message is getting sent properly.

ModuleNotFoundError: No module named 'exceptions'

I'm running this on a fresh Python 3.7 install. I've read somewhere that exceptions is a module from python 2. However, I haven't found a fix yet. Does someone know a solution?

When I run
import gmail
I get:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-82-1c7cf505bc40> in <module>
----> 1 import gmail

/usr/local/lib/python3.7/site-packages/gmail/__init__.py in <module>
     14 __copyright__ = 'Copyright 2013 Charlie Guo'
     15 
---> 16 from .gmail import Gmail
     17 from .mailbox import Mailbox
     18 from .message import Message

/usr/local/lib/python3.7/site-packages/gmail/gmail.py in <module>
      1 import imaplib
      2 from mailbox import Mailbox
----> 3 from exceptions import *
      4 import re
      5 

ModuleNotFoundError: No module named 'exceptions'

sending a mail from gmail.cli with attachment in Python2.7 raises UnicodeError when path string is multibyte

Hello

thanks for writing such useful library

I have faced a problem when using this library on

  • Windows10
  • Python2.7
  • Japanese environment
  • sending a mail from gmail.cli
  • pass multibyte (cp932) string to parameter attachment

reproduction steps below:

In Python2.7

C:\temp>python -V
Python 2.7.11

C:\temp>c:\Python27\Scripts\virtualenv myenv
New python executable in C:\temp\myenv\Scripts\python.exe
Installing setuptools, pip, wheel...done.

C:\temp>myenv\Scripts\activate
(myenv) C:\temp>pip install gmail
Collecting gmail
Installing collected packages: gmail
Successfully installed gmail-0.6.2

(myenv) C:\temp>python -m gmail.cli --username %GMAIL_USERNAME% --password %GMAIL_PASSWORD% --to=%GMAIL_USERNAME% --subject サブジェクト --body ボディ --attachment=c:\temp\無題.png
Traceback (most recent call last):
  File "c:\python27\Lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\temp\myenv\lib\site-packages\gmail\cli.py", line 52, in <module>
    cli()
  File "C:\temp\myenv\lib\site-packages\gmail\cli.py", line 47, in cli
    attachments=results.attachment)
  File "C:\temp\myenv\lib\site-packages\gmail\message.py", line 76, in __init__
    self.root.attach(self._attachment(a))
  File "C:\temp\myenv\lib\site-packages\gmail\message.py", line 114, in _attachment
    attachment.add_header('Content-Disposition','attachment',filename=os.path.basename(a))
  File "c:\python27\Lib\email\message.py", line 411, in add_header
    self._headers.append((_name, SEMISPACE.join(parts)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0x96 in position 10: ordinal not in range(128)

(myenv) C:\temp>python -m gmail.cli --username %GMAIL_USERNAME% --password %GMAIL_PASSWORD% --to=%GMAIL_USERNAME% --subject サブジェクト --body ボディ

(myenv) C:\temp>

In Python3.6 (It works correctly)

C:\temp>c:\Python36\python.exe -V
Python 3.6.0

C:\temp>c:\Python36\python.exe -m venv myenv_py3

C:\temp>myenv_py3\Scripts\activate.bat
(myenv_py3) C:\temp>pip install gmail
Collecting gmail
  Using cached gmail-0.6.2.tar.gz
Installing collected packages: gmail
  Running setup.py install for gmail ... done
Successfully installed gmail-0.6.2

(myenv_py3) C:\temp>python -m gmail.cli --username %GMAIL_USERNAME% --password %GMAIL_PASSWORD% --to=%GMAIL_USERNAME% --subject サブジェクト --body ボディ --attachment=c:\temp\無題.png

(myenv_py3) C:\temp>python -m gmail.cli --username %GMAIL_USERNAME% --password %GMAIL_PASSWORD% --to=%GMAIL_USERNAME% --subject サブジェクト --body ボディ

(myenv_py3) C:\temp>

[UPDATED]'GMail' object has no attribute 'session'

Hello

first thanks for porting this lib to python 3.

I have some trouble to use it on python 3 because with this script :

from gmail import GMail,Message

gmail = GMail(bytes(u"'A.User <"+gmail_user+">'", 'utf-8'), bytes(u"'"+gmail_password+"'", 'utf-8'))
msg = Message(bytes(u"'"+object+"'"), to=bytes(u"'xyz <"+toaddr+">'"), text=bytes(u"'"+message+"'"))
gmail.send(msg)

it keeps returning me this result :

/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 "/Users/Yasser/Dropbox/Projects File/Python Apps/1. Applications/Talaria/Talaria.py"
Traceback (most recent call last):
File "/Users/Yasser/Dropbox/Projects File/Python Apps/1. Applications/Talaria/Talaria.py", line 8, in
gmail = GMail(bytes(u"'A.User <"+gmail_user+">'", 'utf-8'), bytes(u"'"+gmail_user+"'", 'utf-8'))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/gmail/gmail.py", line 57, in init
self.username = parseaddr(username)[1]
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/utils.py", line 218, in parseaddr
addrs = _AddressList(addr).addresslist
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/_parseaddr.py", line 500, in init
self.addresslist = self.getaddrlist()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/_parseaddr.py", line 253, in getaddrlist
ad = self.getaddress()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/_parseaddr.py", line 263, in getaddress
self.gotonext()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/email/_parseaddr.py", line 236, in gotonext
if self.field[self.pos] in self.LWS + '\n\r':
TypeError: 'in ' requires string as left operand, not int
Exception ignored in: <bound method GMail.del of <gmail.gmail.GMail object at 0x1022230f0>>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/gmail/gmail.py", line 144, in del
self.close()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/gmail/gmail.py", line 136, in close
if self.session:
AttributeError: 'GMail' object has no attribute 'session'

Process finished with exit code 1

Thank you for your help^^

Unable to authenticate into my gmail account with app generated password

Hi,

When I try to use your gmail library with my email address and a generated app password for my gmail account, I receive an error: Username and Password not accepted. I followed your reference material for setting up a generated password with Gmail and passed this into the Gmail instance. I'm using python version 2.7.

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.