Mail::TempAddress - module for managing simple, temporary mailing addresses


    use Mail::TempAddress;
    my $mta = Mail::TempAddress->new( 'addresses' );


Sometimes, you just need a really simple mailing address to last for a few days. You want it to be easy to create and easy to use, and you want it to be sufficiently anonymous that your real address isn't ever exposed.

Mail::TempAddress, Mail::TempAddress::Addresses, and Mail::TempAddress::Address make it easy to create a temporary mailing address system.



Please see the README file in this distribution for installation and configuration instructions. You'll need to configure your mail server and your DNS, but you only need to do it once. The rest of these instructions assume you've installed Mail::TempAddress to handle all mail coming to addresses in the subdomain


To create a new temporary address, send an e-mail to the address In the subject of the message, include the phrase *new*. You will receive a response informing you that the address has been created. The message will include the new address. In this case, it might be

Simply provide this address when required to register at a web site (for example).

You can specify additional directives when creating an address. Please see Directives for more information.


Every message sent to your temporary address will be resent to the address you used to create the address. The sender will not see your actual address.


Every message relayed to your actual address will contain a special Reply-To header keyed to the sender. Thus, a message from may have a Reply-To header of Be sure to send any replies to this address so that the message may be relayed from your temporary address.


Temporary addresses have two attributes. You can specify these attributes by including directives when you create a new address.

Directives go in the body of the creation message. They take the form:

    Directive: option


This directive governs how long the address will last. After its expiration date has passed, no one may send a message to the address. Everyone will then receive an error message indicating that the address does not exist.

This attribute is not set by default; addresses do not expire. To enable it, use the directive form:

    Expires: 7d2h

This directive will cause the address to expire in seven days and two hours. Valid time units are:

  • m, for minute. This is sixty (60) seconds.

  • h, for hour. This is sixty (60) minutes.

  • d, for day. This is twenty-four (24) hours.

  • w, for week. This is seven (7) days.

  • M, for month. This is thirty (30) days.

This should suffice for most purposes.


This is a single line that describes the purpose of the address. If provided, it will be sent in the X-MTA-Description header in all messages sent to the address. By default, it is blank. To set a description, use the form:

    Description: This address was generated to enter a contest.


  • new( $address_directory, [ Filehandle => $fh, Storage => $addys, Message => $mess ] )

    new() takes one mandatory argument and three optional arguments. $address_directory is the path to the directory where address data is stored. You can usually get by with just the mandatory argument.

    $fh is a filehandle (or a reference to a glob) from which to read an incoming message. If not provided, M::TA will read from STDIN, as that is how mail filters work.

    $addys should be an Storage object (which manages the storage of temporary addresses). If not provided, M::TA will use Mail::TempAddress::Addresses by default.

    $mess should be a Mail::Message object (representing an incoming e-mail message) to the constructor. If not provided, M::TA will use Mail::Message by default.

  • process()

    Processes one incoming message.

  • expansion_pattern()

    Returns a compiled regex to find expanded e-mail addresses (of the form If you've set your mail server to use a delimiter other than +, override this method. For example, Andy Lester uses addresses of the form What a nut.




No known bugs.


  • allow nicer name generation

  • allow new message creation to send an initial message

  • allow address creation to be restricted to a set of users


Copyright (c) 2003 - 2009 chromatic. Some rights reserved. You may use, modify, and distribute this module under the same terms as Perl 5.10 itself.