#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12

    Smtplib.SMTP("localhost") existance problem


    Well in the other thread where netytan posted his script for a Smtp sendmail().

    On the

    Code:
    server = smtplib.SMTP("localhost")
     server.sendmail(address[0], address[1:], message)
     server.quit()
    on the first line the server = smtplib.SMTP()
    I cant called it

    Code:
    Traceback (most recent call last):
      File "E:/smtplib.py", line 16, in -toplevel-
        mail(('someone@somewhere.com', 'sometwo@somewhere.com'), 'subject', 'message')
      File "E:/smtplib.py", line 10, in mail
        server = smtplib.SMTP("localhost")
    AttributeError: 'module' object has no attribute 'SMTP'
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    Well apparently the module doesn't have a function named SMPT, :/. Search that module on the Python docs page on python.org and view its current functions, that should help you.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    well i looked in the acual module and it is there as a class and i cant use it
    Last edited by monkeyman23555; May 4th, 2005 at 04:28 PM.
  6. #4
  7. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    Can you show us how you imported the module? Maybe you imported it incorrectly.
  8. #5
  9. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Originally Posted by monkeyman23555
    Well in the other thread where netytan posted his script for a Smtp sendmail().

    On the

    Code:
    server = smtplib.SMTP("localhost")
     server.sendmail(address[0], address[1:], message)
     server.quit()
    on the first line the server = smtplib.SMTP()
    I cant called it

    Code:
    Traceback (most recent call last):
      File "E:/smtplib.py", line 16, in -toplevel-
        mail(('someone@somewhere.com', 'sometwo@somewhere.com'), 'subject', 'message')
      File "E:/smtplib.py", line 10, in mail
        server = smtplib.SMTP("localhost")
    AttributeError: 'module' object has no attribute 'SMTP'

    Have you called your own module "smtplib.py"??
    Try renaming it

    grim
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    I reinstalled python and i can't call smtplib from the script but from the IDLE.

    and i did have a file called "stmplib.py", but that was the file it self
    Last edited by monkeyman23555; May 5th, 2005 at 05:33 AM.
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Problem found then, Python does something pretty strange when you import a module with the same name as your program: it tries to import itself. This happens because Python looks in the current directory for any modules that need importing first, so when it sees the file 'whatever.py' it thinks it's found it.

    The solution is simple, rename your file ,

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    Ya I did now and moved it to a new directory :P
  16. #9
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Moving the file to another directory should make no difference, as long as the file wasn't somewhere inside the Python installation directory (bad idea anyway). The problem was simply the files name, but I'm glad you fixed it .

    Do me a favour and try to have less of an attitude when asking for help monkey, or people won't bother.

    Take care,

    Mark.
    programming language development: www.netytan.com Hula

  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    what attitude?
  20. #11
  21. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    There is a general ungrateful, impatient or rude tone in your posts: often one liners which translate into "I already know that but...". Maybe it's just me? In any case I'm not going to find examples or turn this into a fight with you. Just please keep this in mind.

    Later,

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo