No, Seriously. You should be using a REPL. Even if you just use the plain python REPL, it would give you feed back as you try each line. I've updated Steven's notes below...<br><br>> =============start script=============<br>
>><br>>> #!/usr/bin/python<br>>><br>>> import os, smtplib<br>>> system_name = os.getenv('HOSTNAME')<br>>><br>>><br>>> SERVER = localhost <-- <font color="#cc0000">This would have given you an error. That may have caused you to figure out the quoting thing yourself.</font><br>
>><br>>> FROM = "<a href="mailto:me@abc.com">me@abc.com</a>"<br>>> TO = ["<a href="mailto:you@nbc.com">you@nbc.com</a>"]<br>>><br>>> SUBJECT = "Mail from",os.getenv('HOSTNAME') <-- <font color="#cc0000">After storing this variable, if you were to print it you'd realize that it is a Tuple, not a string. The way to create a string is: "Mail from %s" % os.getenv('HOSTNAME')</font><br>
>><br>>> TEXT = "This message is from",os.getenv('HOSTNAME') <-- <font color="#cc0000">Another Tuple.</font><br>>><br>>> message = """\<br>>> From: %s<br>>> To: %s<br>
>> Subject: %s<br>>><br>>> %s<br>>> """ % (FROM, ", ".join(TO), SUBJECT, TEXT)<br>>><br>>> # Send message<br>>><br>>> server = smtplib.STMP(SERVER) <-- <font color="#cc0000">If you are using ipython, typing "smtplib." then hitting [tab] [tab] would have listed every property on the object.</font><br>
>> server.sendmail(FROM, TO, message)<br>>> server.quit()<br>>><br>>> =============end script=============<br>><br>> --<br>> Stephen Haywood<br>> Information Security Consultant<br>> CISSP, GPEN, OSCP<br>
> T: @averagesecguy<br>> W: <a href="http://averagesecurityguy.info">averagesecurityguy.info</a><br>><br>><br>> _______________________________________________<br>> Ale mailing list<br>> <a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
> <a href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a><br>> See JOBS, ANNOUNCE and SCHOOLS lists at<br>> <a href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a><br>
><br>><br><br><br><br>-- <br>.!# RichardBronosky #!.<br><br>