anchor.diff:      MegaSec2 = MegaSec + Sec2 div 1000000,
       {MegaSec2, Sec3, MicroSec}.
   
  +
  +%% @doc Check if an e-mail address is valid
  +is_valid_email(Recipient) ->
  +    Recipient1 = string:strip(z_string:line(binary_to_list(z_convert:to_binary(Recipient)))),
  +    {_RcptName, RecipientEmail} = z_email:split_name_email(Recipient1),
  +    case re:run(RecipientEmail, [$^|re()]++"$", [extended]) of
  +        nomatch   -> false;
  +        {match,_} -> true
  +    end.
  +
  +    re() ->
  +        "(
  +                (\"[^\"\\f\\n\\r\\t\\v\\b]+\")
  +            |   ([\\w\\!\\#\\$\\%\\&\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+
  +                    (\\.[\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\^\`\\|\\{\\}]+)*
  +                )
  +        )
  +        @
  +        (
  +            (
  +                ([A-Za-z0-9\\-])+\\.
  +            )+
  +            [A-Za-z\\-]{2,}
  +        )".
   
   
   %% @doc Simple header encoding.
  
positive.code: % Timeout value for the connection of the spamassassin daemon
  -define(SPAMD_TIMEOUT, 10000).
  
  -record(state, {smtp_relay, smtp_relay_opts, smtp_no_mx_lookups,
                  smtp_verp_as_from, smtp_bcc, override, 
                  smtp_spamd_ip, smtp_spamd_port, sending=[],
                  delete_sent_after}).
  -record(email_queue, {id, retry_on=inc_timestamp(now(), 10), retry=0, 
                        recipient, email, created=now(), sent, 
                        pickled_context}).
  
  
negative.code:     QEmail = #email_queue{id=Id,
                            recipient=Recipient,
                            email=Email,
                            retry_on=inc_timestamp(now(), 0),
                            pickled_context=z_context:pickle(Context)},
      QEmailTransFun = fun() -> mnesia:write(QEmail) end,
      {atomic, ok} = mnesia:transaction(QEmailTransFun),        
      case Email#email.queue orelse length(State#state.sending) > ?EMAIL_MAX_SENDING of
          true -> State;
          false -> spawn_send(Id, Recipient, Email, Context, State)
      end.
  
  
  spawn_send(Id, Recipient, Email, Context, State) ->
      case is_valid_email(Recipient) of
          true ->
              spawn_send_checked(Id, Recipient, Email, Context, State);
          false ->
              %% delete email from the queue and notify the system
              delete_emailq(Id),
              z_notifier:first({email_failed, Id, Recipient}, Context),
              LogEmail = #log_email{
                  severity=?LOG_ERROR, 
                  mailer_status=error,
                  props=[{reason, illegal_address}],
                  message_nr=Id,
                  envelop_to=Email,
                  to_id=proplists:get_value(recipient_id, Email#email.vars),
                  from_id=z_acl:user(Context),
                  content_id=proplists:get_value(id, Email#email.vars),
                  other_id=proplists:get_value(list_id, Email#email.vars),
                  message_template=Email#email.html_tpl
              },
              z_notifier:notify({log, LogEmail}, Context),
              State
      end.
  
  spawn_send_checked(Id, Recipient, Email, Context, State) ->
      F = fun() ->
              MessageId = message_id(Id, Context),
              VERP = "<"++bounce_email(MessageId, Context)++">",
  