Join us at IRC!
You cannot teach a man anything; you can only help him find it within himself. - Galileo
Friday, May 25, 2012
Navigation
Members Online
Total Online: 36
Web Spiders: 14
Guests Online: 35
Members Online: 1

Registered Members: 70209
Newest Member: KalareShou
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Python Email Program (need help debugging)

psychboo
Member



Posts: 1
Location: Canada
Joined: 11.06.10
Rank:
Mad User
Posted on 18-06-10 23:29
I've modified a program I found in the code bank that uses python and the smtplib module in order to send through Gmail servers.
I'm new to python and trying to figure out why the following code is generating errors when run.
Any advice?

#! /usr/bin/env python
import smtplib
import getpass

smtpserver = smtplib.SMTP("smtp.gmail.com",587)
x = smtpserver.ehlo()
print "Connected to "+x[1].split()[0]+" at "+x[1].split()[4]+'\n'
x = smtpserver.starttls()
print x[1]

logged_in = False
print 'Login Required \n'

while not logged_in:
gmail_user = raw_input("User: ")
gmail_pwd = getpass.getpass()
try:
smtpserver.login(gmail_user,gmail_pwd)
logged_in = True
except smtplib.SMTPAuthenticationError:
print 'Incorrect User/Pass combination\n'
print 'Accepted'
to = raw_input("Send to: ")
subject = raw_input("Subject: ")
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + subject + '\n'
print '\n'+header+'\n'+'Type your email below, *q terminates\n'

msg=''
while msg[-3:]!='*q\n':
msg+=raw_input('>')+'\n'

x=''
while x!='y' and x!='n':
x=raw_input('Send? (y/n): ')
if x=='y':
smtpserver.sendmail(gmail_user, to, msg)
smtpserver.close()


If the code seems convoluted PM me and i'll send you a .txt

Edited by psychboo on 18-06-10 23:40
Author

RE: Python Email Program (need help debugging)

wolfmankurd
Member



Posts: 1519
Location: UK
Joined: 30.05.05
Rank:
God
Posted on 19-06-10 00:50
I haven't had a look at it cause like you hinted it looks like eye rape without formatting. Tried the [code] tags? Idk if they protect the formatting? Also post the error outputed it maybe the case that we don't need to run it know the problem.


BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.


Widowmakr@hotmail.com http://LetsHackStuff.com
Author

RE: Python Email Program (need help debugging)

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 19-06-10 04:28
wolfmankurd wrote:
Idk if they protect the formatting?

They do, keeps the tabs and all and it eliminates smileys.

Most people (myself included) won't read code that's more than a few lines long if it doesn't have tabbing. Especially in python since you can't tell what stuff is contained in what loops without tabs.




ynori7 http://halls-of-valhalla.org
Author

RE: Python Email Program (need help debugging)

wolfmankurd
Member



Posts: 1519
Location: UK
Joined: 30.05.05
Rank:
God
Posted on 19-06-10 12:30
It'd be pretty sweet if we had code bin style formatting from the [code] tags. Like keyword colouring. Op why not just post a link to codebin.

Anyway I can't quiet work out your formatting I tried it in http://codepad.org/ (which is an awesome site someone posted in the IRC I think it was NotMyFault). If you put it on there and link us then we'd have the pastebin style formatting and highlighting and be able to see the errors on the fly.


BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.




Edited by wolfmankurd on 19-06-10 12:31
Widowmakr@hotmail.com http://LetsHackStuff.com
Author

RE: Python Email Program (need help debugging)

only_samurai
[IRC Rockstar]

Posts: 984
Location: idling in some random irc channel
Joined: 18.08.06
Rank:
.|unranked|.
Posted on 19-06-10 16:32
Additionally, could you post a stack trace of the error the program is having? If it's not a programmatic error and is a logical error (e.g. the program runs but doesn't do what you think it's supposed to), could you post a brief descblockedription explaining where the problem is?




The problem with a fool-proof system, is eliminating the fool.

"His name is Cereal Killer...Like Fruitloops."
If you cut me, I bleed binary.

http://blog.psych0tik.net/
http://blog.psych0tik.net
Author

RE: Python Email Program (need help debugging)

4rm4g3dd0n
Member



Posts: 904
Location: Louisville,Ky
Joined: 09.10.07
Rank:
God
Posted on 21-06-10 23:59
there are language differences between python 2 and python 3
myself i prefer 2 but that's because most of the code I've written was in 2
and I don't like modifying all the time

try " instead of ' for boolean text if using python 3 I've had problems with that plus annoying small things like

print "printed"
print ("printed";)

from md5 import new

from hashlib

x = hashlib.md5 ("string";)
new = hashlib.update (x)

and so on


All I Know Is That I Don't Know Nothing .... Operation Ivy

c:/users
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.