Permalink
Browse files

Version 0.1.0

  • Loading branch information...
0 parents commit 9b50b902fe4ffff7b40501b54ad53d5eccf072f8 Matt Mower committed Oct 4, 2007
@@ -0,0 +1,5 @@
+== 1.0.0 / 2007-10-03
+
+* 1 major enhancement
+ * Birthday!
+
@@ -0,0 +1,6 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/mailtrap
+lib/mailtrap.rb
@@ -0,0 +1,62 @@
+mailtrap
+ by Matt Mower <self@mattmower.com>
+ http://matt.blogs.it/
+
+== DESCRIPTION:
+
+Mailtrap is a mock SMTP server for use in Rails development.
+
+Mailtrap waits on your choosen port for a client to connect and talks _just enough_ SMTP protocol for ActionMailer to successfully deliver its message.
+
+Mailtrap makes *no* attempt to actually deliver messages and, instead, writes them into sequentially numbered files on disk (hence the name Mail_trap_).
+
+You can configure the hostname (default: localhost) and port (default: 2525) for the server and also where the messages get written (default: /var/tmp). Messages will get written to files named smtp0001.msg, smtp0002.msg, and so on.
+
+== FEATURES/PROBLEMS:
+
+* Lightweight, no setup
+* Runs as a daemon with start, stop, etc..
+* Tested with ActionMailer's SMTP delivery method
+* Very, very, dumb ... might not work with an arbitrary SMTP client
+
+== SYNOPSIS:
+
+* mailtrap --help (to see Daemonization options)
+* mailtrap start --help (to see Mailtrap options)
+
+* mailtrap start --host localhost --port 8025 --once --msgdir=/var/tmp
+
+== REQUIREMENTS:
+
+* Rubygems
+* Daemons rubygem
+* Trollop rubygem
+
+== INSTALL:
+
+* sudo gem install -y mailtrap
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2007 Matt Mower, Software Heretics
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+require './lib/mailtrap.rb'
+
+Hoe.new('mailtrap', Mailtrap::VERSION) do |p|
+ p.rubyforge_name = 'rubymatt'
+ p.author = 'Matt Mower'
+ p.email = 'self@mattmower.com'
+ p.summary = 'Mailtrap is a mock SMTP server for use in Rails development'
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+ p.remote_rdoc_dir = 'mailtrap'
+ p.extra_deps << ['daemons','>= 1.0.8']
+ p.extra_deps << ['trollop','>= 1.7']
+end
+
+# vim: syntax=Ruby
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+#
+# Run the mailtrap server
+#
+
+require 'rubygems'
+require 'daemons'
+require 'mailtrap'
+
+opts = Trollop::options do
+ opt :host, "The host SMTP clients will connect to", :default => 'localhost'
+ opt :port, "The port SMTP clients will connect to", :default => 2525
+ opt :once, "Whether to terminate after serving the first client", :default => false
+ opt :msgdir, "Where messages get stored", :default => "/var/tmp"
+end
+
+options = {
+ :dir_mode => :normal,
+ :dir => '/var/tmp',
+ :multiple => true,
+ :mode => :exec,
+ :backtrace => true,
+ :log_output => true
+}
+
+Daemons.run_proc( 'mailtrap', options ) do
+ Mailtrap.new( opts[:host], opts[:port], opts[:once], opts[:msgdir] )
+end
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Class: Mailtrap</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="classHeader">
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Class</strong></td>
+ <td class="class-name-in-header">Mailtrap</td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>In:</strong></td>
+ <td>
+ <a href="../files/lib/mailtrap_rb.html">
+ lib/mailtrap.rb
+ </a>
+ <br />
+ </td>
+ </tr>
+
+ <tr class="top-aligned-row">
+ <td><strong>Parent:</strong></td>
+ <td>
+ Object
+ </td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+ <div id="description">
+ <p>
+<a href="Mailtrap.html">Mailtrap</a> creates a TCP server that listens on a
+specified port for SMTP clients. Accepts the connection and talks just
+enough of the SMTP protocol for them to deliver a message which it writes
+to disk.
+</p>
+
+ </div>
+
+
+ </div>
+
+ <div id="method-list">
+ <h3 class="section-bar">Methods</h3>
+
+ <div class="name-list">
+ <a href="#M000002">accept</a>&nbsp;&nbsp;
+ <a href="#M000001">new</a>&nbsp;&nbsp;
+ <a href="#M000004">serve</a>&nbsp;&nbsp;
+ <a href="#M000003">write</a>&nbsp;&nbsp;
+ </div>
+ </div>
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+
+ <div id="constants-list">
+ <h3 class="section-bar">Constants</h3>
+
+ <div class="name-list">
+ <table summary="Constants">
+ <tr class="top-aligned-row context-row">
+ <td class="context-item-name">VERSION</td>
+ <td>=</td>
+ <td class="context-item-value">'0.1.0'</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+
+
+
+
+
+ <!-- if method_list -->
+ <div id="methods">
+ <h3 class="section-bar">Public Class methods</h3>
+
+ <div id="method-M000001" class="method-detail">
+ <a name="M000001"></a>
+
+ <div class="method-heading">
+ <a href="Mailtrap.src/M000001.html" target="Code" class="method-signature"
+ onclick="popupCode('Mailtrap.src/M000001.html');return false;">
+ <span class="method-name">new</span><span class="method-args">( host, port, once, msgdir )</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Create a <a href="Mailtrap.html#M000001">new</a> <a
+href="Mailtrap.html">Mailtrap</a> on the specified host:port. If once it
+true it will listen for one message then exit. Specify the msgdir where
+messages are written.
+</p>
+ </div>
+ </div>
+
+ <h3 class="section-bar">Public Instance methods</h3>
+
+ <div id="method-M000002" class="method-detail">
+ <a name="M000002"></a>
+
+ <div class="method-heading">
+ <a href="Mailtrap.src/M000002.html" target="Code" class="method-signature"
+ onclick="popupCode('Mailtrap.src/M000002.html');return false;">
+ <span class="method-name">accept</span><span class="method-args">( service )</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Service one or more SMTP client connections
+</p>
+ </div>
+ </div>
+
+ <div id="method-M000004" class="method-detail">
+ <a name="M000004"></a>
+
+ <div class="method-heading">
+ <a href="Mailtrap.src/M000004.html" target="Code" class="method-signature"
+ onclick="popupCode('Mailtrap.src/M000004.html');return false;">
+ <span class="method-name">serve</span><span class="method-args">( connection )</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Talk pidgeon-SMTP to the client to get them to hand over the message and go
+away.
+</p>
+ </div>
+ </div>
+
+ <div id="method-M000003" class="method-detail">
+ <a name="M000003"></a>
+
+ <div class="method-heading">
+ <a href="Mailtrap.src/M000003.html" target="Code" class="method-signature"
+ onclick="popupCode('Mailtrap.src/M000003.html');return false;">
+ <span class="method-name">write</span><span class="method-args">( from, to_list, message )</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Write a plain text dump of the incoming email to a text file. The file will
+be in the @msgdir folder and will be called smtp0001.msg, smtp0002.msg, and
+so on.
+</p>
+ </div>
+ </div>
+
+
+ </div>
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <title>new (Mailtrap)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre><span class="ruby-comment cmt"># File lib/mailtrap.rb, line 18</span>
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">once</span>, <span class="ruby-identifier">msgdir</span> )
+ <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
+ <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
+ <span class="ruby-ivar">@once</span> = <span class="ruby-identifier">once</span>
+ <span class="ruby-ivar">@msgdir</span> = <span class="ruby-identifier">msgdir</span>
+
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Mailtrap starting at #{@host}:#{port} and writing to #{@msgdir}&quot;</span>
+ <span class="ruby-identifier">service</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>( <span class="ruby-ivar">@host</span>, <span class="ruby-ivar">@port</span> )
+ <span class="ruby-identifier">accept</span>( <span class="ruby-identifier">service</span> )
+ <span class="ruby-keyword kw">end</span></pre>
+</body>
+</html>
Oops, something went wrong.

0 comments on commit 9b50b90

Please sign in to comment.