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