anchor.diff:  
   -spec set_email(#jid{}, string()) -> ok | {error, atom()}.
   set_email(JID, Email) ->
  -    #jid{luser = User, lserver = Server} = JID,
  -    F = fun() ->
  -        mnesia:write(#private_email{user = {User, Server}, email = Email})
  -    end,
  -    case mnesia:transaction(F) of
  -        {atomic, _} -> ok;
  -        {aborted, _Reason} ->
  -            ?ERROR_MSG("Couldnt set private Email '~p' for '~p': ~p",
  -                       [Email, JID, _Reason]),
  -            {error, aborted}
  +    case re:run(Email, "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]+") of
  +        {match, _} ->
  +            #jid{luser = User, lserver = Server} = JID,
  +            F = fun() ->
  +                mnesia:write(#private_email{user = {User, Server},
  +                                            email = Email})
  +            end,
  +            case mnesia:transaction(F) of
  +                {atomic, _} -> ok;
  +                {aborted, _Reason} ->
  +                    ?ERROR_MSG("Couldnt set private Email '~p' for '~p': ~p",
  +                               [Email, JID, _Reason]),
  +                    {error, aborted}
  +            end;
  +        _ ->
  +            {error, invalid_email}
       end.
   
   -spec get_email(#jid{}) -> string() | {error, atom()}.
  
positive.code: 
      update_table(),
  
      ejabberd_hooks:add(adhoc_local_items, Host,
                         ?MODULE, private_email_items, 50),
      ejabberd_hooks:add(adhoc_local_commands, Host,
  
negative.code:         get_email/1,
          delete_email/1,
  
          % User events
          user_removed/2,
          user_registered/2,
  
          % Ad-hoc commands
          private_email_items/4,
          private_email_commands/4
  