<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>prestia.org</title>
 <link href="http://prestia.org/atom.xml" rel="self"/>
 <link href="http://prestia.org"/>
 <updated>2012-10-19T16:30:14-04:00</updated>
 <id>http://prestia.org</id>
 <author>
   <name>prestia.org</name>
 </author>

 
 <entry>
   <title>(Contextual) Dupe Destroyer!</title>
   <link href="http://prestia.org/code/2012/10/15/_contextual_-dupe-destroyer/"/>
   <updated>2012-10-15T15:28:02-04:00</updated>
   <id>http://prestia.org/code/2012/10/15/_contextual_-dupe-destroyer</id>
   <content type="html">&lt;p&gt;I generally enjoy OS X, but I have a recurring problem with duplicate entries appearing in my &quot;Open With&quot; contextual menu. At any given time I have five instances of &lt;a href=&quot;http://www.pixelmator.com&quot;&gt;Pixelmator&lt;/a&gt;, two instances of &lt;a href=&quot;https://developer.apple.com/xcode/&quot;&gt;Xcode&lt;/a&gt;, and three instances of &lt;a href=&quot;https://github.com/textmate/textmate&quot;&gt;TextMate&lt;/a&gt; just daring me to choose the correct one. It's relatively simple to fix this problem using Terminal, but I can never remember the proper commands and I know that not everyone is comfortable using Terminal. This led me to create &lt;em&gt;Destroy All Dupes!&lt;/em&gt;, a simple application that cleans up your contextual menus in a matter of seconds.&lt;/p&gt;

&lt;p&gt;I wrote &lt;em&gt;Destroy All Dupes!&lt;/em&gt; to work on my machine (a MacBook Air running 10.8.2), but it should work on just about any system. That said, &lt;strong&gt;&lt;em&gt;this software is offered as-is and is used at your own risk&lt;/em&gt;&lt;/strong&gt;. If you can live with those terms, you can &lt;a href=&quot;http://dl.dropbox.com/u/2199929/Dad.zip&quot;&gt;download &lt;em&gt;Destroy All Dupes!&lt;/em&gt;&lt;/a&gt;. If you're uncomfortable with those terms or don't trust an application provided by some yahoo on the Internet, you can usually fix the problem by typing the following into terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Library&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Frameworks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CoreServices&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;framework&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Versions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Frameworks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LaunchServices&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;framework&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Versions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Support&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;./&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lsregister&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kill&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




&lt;br/&gt;

</content>
 </entry>
 
 <entry>
   <title>Thoughts about Discovery</title>
   <link href="http://prestia.org/gubbish/2012/04/18/thoughts-about-discovery/"/>
   <updated>2012-04-18T14:13:57-04:00</updated>
   <id>http://prestia.org/gubbish/2012/04/18/thoughts-about-discovery</id>
   <content type="html">&lt;p&gt;Watching Discovery &lt;a href=&quot;http://tumblr.anthonyprestia.com/post/21323925548/one-more-shuttle-related-post-im-really-trying&quot;&gt;hitch a ride to DC on the back of a 747&lt;/a&gt; Tuesday morning was an odd experience. On the one hand, I've never romanticized the shuttle program. The technology was way past its prime and the entire program was unnecessarily dangerous. As a general rule, I'm wary of supporting any technology that &lt;a href=&quot;http://science.ksc.nasa.gov/shuttle/missions/51-l/docs/rogers-commission/Appendix-F.txt&quot;&gt;Richard Feynman compares to playing Russian roulette&lt;/a&gt;. Still, the death of the shuttle program is symbolic (in my mind) of a much larger problem.&lt;/p&gt;

&lt;p&gt;For all its faults, the shuttle program was inspiring. Discovery is a 165,000-pound reminder of a time when our country was investing in our education, tackling difficult technological problems, and securing the future of not just our country but our species. When I was a kid, I had no doubt we would be on Mars by now. Vacations to the moon? Absolutely. Sadly, none of this came to fruition. We're not growing to become an interplanetary species; instead, we are becoming increasingly obsessed with petty problems. We've stopped developing technology to extend our reach beyond our planet and started developing technology to &lt;a href=&quot;https://www.eff.org/deeplinks/2011/09/government-internet-surveillance-starts-eyes-built&quot;&gt;extend our reach into the private lives of our citizenry&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Maybe I'm wrong. Maybe a 26-year-old spacecraft stopped being inspiring decades ago. Maybe it was just a sad reminder that we, as a society, have stopped dreaming. Maybe it was time to let go.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>It's been a while, but we have a new issue of Phrack</title>
   <link href="http://prestia.org/gubbish/2012/04/14/it-s-been-a-while-but-we-have-a-new-issue-of-phrack/"/>
   <updated>2012-04-14T18:24:08-04:00</updated>
   <id>http://prestia.org/gubbish/2012/04/14/it-s-been-a-while-but-we-have-a-new-issue-of-phrack</id>
   <content type="html">&lt;p&gt;It's been almost a year and a half, so there's no sense in wasting your time. Read Phrack #68 or download the tarball &lt;a href=&quot;http://phrack.org/issues.html?issue=68&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Controlling external programs using Ruby's Kernel#exec</title>
   <link href="http://prestia.org/code/2012/04/12/controlling-external-programs-using-ruby-s-Kernel-exec/"/>
   <updated>2012-04-12T13:02:17-04:00</updated>
   <id>http://prestia.org/code/2012/04/12/controlling-external-programs-using-ruby-s-Kernel-exec</id>
   <content type="html">&lt;p&gt;I was recently writing a small script that would launch the spectacular &lt;a href=&quot;http://mitmproxy.org/&quot;&gt;&lt;code&gt;mitmdump&lt;/code&gt;&lt;/a&gt; while simultaneously performing application testing using &lt;a href=&quot;http://watirwebdriver.com/&quot;&gt;&lt;code&gt;watir-webdriver&lt;/code&gt;&lt;/a&gt;. To make this work, I needed a dead simple way to launch &lt;code&gt;mitmdump&lt;/code&gt; as a concurrent background process that could easily be closed by sending a &lt;code&gt;SIGINT&lt;/code&gt; once the script was done performing its tests. I didn't need access to stdin, stdout, or stderr and I didn't need to know if mitmdump ran successfully.&lt;/p&gt;

&lt;p&gt;Anyway, sounds like a simple enough task, right? Especially when you consider that Ruby has no shortage of ways to execute external programs--the best known examples including &lt;code&gt;Kernel#exec&lt;/code&gt;, &lt;code&gt;Kernel#system&lt;/code&gt;, &lt;code&gt;IO#popen&lt;/code&gt;, &lt;code&gt;Open3#popen3&lt;/code&gt;, and the simple backtick--but how to choose?&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;IO#popen&lt;/code&gt; &amp;amp; &lt;code&gt;Open3#popen3&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;With &lt;code&gt;IO#popen&lt;/code&gt; and &lt;code&gt;Open3#popen3&lt;/code&gt;, the external program is run as a subprocess and its standard input and output are connected to the returned IO object. &lt;code&gt;Open3#popen3&lt;/code&gt; has the added benefit of allowing you to independently capture standard error; however, you can still obtain stderr using &lt;code&gt;IO#popen&lt;/code&gt; by redirecting the stderr stream to the stdout stream with &lt;code&gt;2&amp;gt;&amp;amp;1&lt;/code&gt;. While there are all sorts of benefits to using these methods, I simply didn't need the level of control they provide. Instead, I just needed something fast and functional.&lt;/p&gt;

&lt;h4&gt;Backticks&lt;/h4&gt;

&lt;p&gt;Backticks are arguably the simplest and best known way to execute an external program or shell script. When using backticks, the completed subprocess returns the actual stdout of the executed program. If needed, you can obtain the exit status code and process id of the program using &lt;code&gt;$?&lt;/code&gt; variable. It is worth noting that you do not have real-time access to a program run in this way. Output is only returned when the process finishes. This made backticks a non-starter because I couldn't run &lt;code&gt;mitmdump&lt;/code&gt; concurrently with my &lt;code&gt;watir-webdriver&lt;/code&gt; test scripts.&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;Kernel#exec&lt;/code&gt; &amp;amp; &lt;code&gt;Kernel#system&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;Kernel#exec&lt;/code&gt; replaces the current process by invoking the given external program or shell command. This means that any additional Ruby after the call to &lt;code&gt;Kernel#exec&lt;/code&gt; will not be executed. This is a very simple and non-interactive invocation that does not provide access to stdin, stdout, stderr, or the process id. &lt;code&gt;Kernel#system&lt;/code&gt; is similar, but has a few small differences. Unlike &lt;code&gt;Kernel#exec&lt;/code&gt;, &lt;code&gt;Kernel#system&lt;/code&gt; runs in a subshell and does not replace the current process. &lt;code&gt;Kernel#system&lt;/code&gt; also allows you to obtain the exit status code using the &lt;code&gt;$?&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;For my purposes, &lt;code&gt;Kernel#exec&lt;/code&gt; and &lt;code&gt;Kernel#system&lt;/code&gt; seemed like the simplest choices, but both have one obvious drawback: It gets a bit tricky sending a SIGINT to a process when you don't know the process id. So, that lead to the final problem:&lt;/p&gt;

&lt;h4&gt;How do you obtain the pid for a process executed using &lt;code&gt;Kernel#exec&lt;/code&gt; or &lt;code&gt;Kernel#system&lt;/code&gt;?&lt;/h4&gt;

&lt;p&gt;The solution is relatively simple, but not something I've seen widely documented online. The trick is to use &lt;code&gt;Process#fork&lt;/code&gt; to initiate a subprocess that then executes the external program or shell script using &lt;code&gt;Kernel#system&lt;/code&gt; or &lt;code&gt;Kernel#exec&lt;/code&gt;. I opted to use &lt;code&gt;Kernel#exec&lt;/code&gt; because it simply takes over the forked subprocess whereas &lt;code&gt;Kernel#system&lt;/code&gt; would launch an additional subprocess. This means that you can simply assign the forked subprocess to a variable and then exit the external program or shell script by sending it a &lt;code&gt;SIGINT&lt;/code&gt; using &lt;code&gt;Process#kill&lt;/code&gt;. Sample code below:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# Launches mitmdump in a forked subprocess&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;fork&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;mitmdump -w &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream_file&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Additional Ruby code goes here&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Send SIGINT to kill the mitmproxy subprocess&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Process&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kill&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;INT&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
 </entry>
 
 <entry>
   <title>A simple, gem-free Ruby method for sending Gmail</title>
   <link href="http://prestia.org/code/2012/04/10/a-simple-gem-free-ruby-method-for-sending-gmail/"/>
   <updated>2012-04-10T15:17:57-04:00</updated>
   <id>http://prestia.org/code/2012/04/10/a-simple-gem-free-ruby-method-for-sending-gmail</id>
   <content type="html">&lt;p&gt;After digging through countless posts trying to find a quick and easy way to send Gmail using Ruby, I eventually had to come up with something on my own. Most solutions online require installing Gmail-specific gems (unnecessary) or are based on versions of Ruby prior to 1.8.7, which added native TLS support to &lt;code&gt;Net::SMTP&lt;/code&gt;. The following code was inspired by a &lt;a href=&quot;http://blog.jerodsanto.net/2009/02/a-simple-ruby-method-to-send-emai/&quot;&gt;great little method by Jerod Santo&lt;/a&gt;, but has been expanded to work with Gmail and &lt;code&gt;Net::SMTP&lt;/code&gt;'s native TLS support:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;net/smtp&amp;#39;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;send_gmail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{})&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;smtp.gmail.com&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;       &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;587&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:from_dom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;your_domain&amp;gt;&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:login&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;your_login&amp;gt;&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:pass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;       &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;your_password&amp;gt;&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:auth_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:plain&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:from&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;       &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;your_email&amp;gt;&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:from_alias&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;your_name&amp;gt;&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:subject&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Default subject.&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;       &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Default body.&amp;#39;&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;From: #{opts[:from_alias]} &amp;lt;#{opts[:from]}&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;To: &amp;lt;#{to}&amp;gt;&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;Subject: #{opts[:subject]}&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;   &lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;#{opts[:body]}&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;smtp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Net&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SMTP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:server&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;smtp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;enable_starttls&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;smtp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:from_dom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:login&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:pass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:auth_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;smtp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;smtp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;send_message&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;opts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:from&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




&lt;br/&gt;


&lt;p&gt;To use the method, first fill in the defaults for &lt;code&gt;opts[:from_dom]&lt;/code&gt;, &lt;code&gt;opts[:login]&lt;/code&gt;, &lt;code&gt;opts[:pass]&lt;/code&gt;, &lt;code&gt;opts[:from]&lt;/code&gt;, &lt;code&gt;opts[:from_alias]&lt;/code&gt;, and any others you would like to change. After that, everything except the &lt;code&gt;to&lt;/code&gt; argument is optional. Here are a few sample invocations:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# Send an email to person@domain.com with the default subject line and message body:&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;send_gmail&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;person@domain.com&amp;quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Send an email to person@domain.com with a custom subject line and message body:&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;send_gmail&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;person@domain.com&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:subject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;This is the subject line&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:body&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Hello, world! This is the body of my message.&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;



</content>
 </entry>
 
 
</feed>