Follow us on Twitter!
Society leans ever heavily on computers, if you have the power to take out computers you can take out society. - cubeman372
Wednesday, April 23, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 19
Guests Online: 16
Members Online: 3

Registered Members: 82877
Newest Member: MWiki
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:
Guest
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)


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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.


Author

RE: Python Email Program (need help debugging)

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
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.


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Python Email Program (need help debugging)


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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.




Edited by on 19-06-10 12:31
Author

RE: Python Email Program (need help debugging)


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
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 description explaining where the problem is?




Author

RE: Python Email Program (need help debugging)

4rm4g3dd0n
Member



Posts: 904
Location: Louisville,Ky
Joined: 09.10.07
Rank:
Active User
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"Wink

from md5 import new

from hashlib

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

and so on


a1.sphotos.ak.fbcdn.net/hphotos-ak-snc6/285477_168984629836698_100001754862141_374762_5098511_n.jpg
All I Know Is That I Don't Know Nothing .... Operation Ivy

c:/users