Exemplo n.º 1
0
  QCString dispositionNotificationBodyContent( const QString & r,
					       const QCString & o,
					       const QCString & omid,
					       DispositionType d,
					       ActionMode a,
					       SendingMode s,
					       const QValueList<DispositionModifier> & m,
					       const QString & special )
  {
    // in Perl: chomp(special) 
    QString spec;
    if ( special.endsWith("\n") )
      spec = special.left( special.length() - 1 );
    else
      spec = special;

    // std headers:
    QCString result = reportingUAField();
    result += orginalRecipient( o );
    result += finalRecipient( r );
    result += originalMessageID( omid );
    result += dispositionField( d, a, s, m );

    // headers that are only present for certain disposition {types,modifiers}:
    if ( d == Failed )
      result += "Failure: " + encodeRFC2047String( spec, "utf-8" ) + "\n";
    else if ( m.contains( Error ) )
      result += "Error: " + encodeRFC2047String( spec, "utf-8" ) + "\n";
    else if ( m.contains( Warning ) )
      result += "Warning: " + encodeRFC2047String( spec, "utf-8" ) + "\n";

    return result;
  }
Exemplo n.º 2
0
bool Recipient::valid() const
{
    if ( action() == Unknown )
        return false;

    if ( status().isEmpty() )
        return false;

    if ( !finalRecipient() )
        return false;

    return true;
}
Exemplo n.º 3
0
EString Recipient::dsnParagraph() const
{
    if ( !valid() )
        return "";

    EStringList l;
    EString s;

    // [ original-recipient-field CRLF ]
    if ( originalRecipient() && originalRecipient() != finalRecipient() )
        l.append( "Original-Recipient: rfc822;" +
                  originalRecipient()->lpdomain() );

    // final-recipient-field CRLF
    if ( finalRecipient() )
        l.append( "Final-Recipient: rfc822;" +
                  finalRecipient()->lpdomain() );

    // action-field CRLF
    switch ( action() ) {
    case Unknown:
        l.append( "Action: unknown" );
        break;
    case Failed:
        l.append( "Action: failed" );
        break;
    case Delayed:
        l.append( "Action: delayed" );
        break;
    case Delivered:
        l.append( "Action: delivered" );
        break;
    case Relayed:
        l.append( "Action: relayed" );
        break;
    case Expanded:
        l.append( "Action: expanded" );
        break;
    }

    // status-field CRLF
    if ( !status().isEmpty() )
        l.append( "Status: " + status() );
    // [ remote-mta-field CRLF ]
    if ( !remoteMTA().isEmpty() )
        l.append( "Remote-Mta: dns;" + remoteMTA() );


    // [ diagnostic-code-field CRLF ]
    if ( !diagnosticCode().isEmpty() )
        l.append( "Diagnostic-Code: smtp;" + diagnosticCode() );

    // [ last-attempt-date-field CRLF ]
    if ( lastAttempt() )
        l.append( "Last-Attempt-Date: " + lastAttempt()->rfc822() );

    // [ final-log-id-field CRLF ]
    if ( !finalLogId().isEmpty() )
        l.append( "Final-Log-Id: smtp;" + finalLogId() );

    // we don't set will-retry-until. it only applies to delay dsns,
    // which we don't send.

    return l.join( "\n" );
}
Exemplo n.º 4
0
EString Recipient::plainTextParagraph() const
{
    if ( !valid() )
        return "";

    EString s;
    EString a;

    if ( finalRecipient() && originalRecipient() &&
         finalRecipient()->toString(false) !=
         originalRecipient()->toString(false) ) {
        a.append( finalRecipient()->lpdomain() );
        a.append( " (forwarded from " );
        a.append( originalRecipient()->lpdomain() );
        a.append( ")" );
    }
    else if ( finalRecipient() ) {
        a.append( finalRecipient()->lpdomain() );
    }
    else if ( originalRecipient() ) {
        a.append( originalRecipient()->lpdomain() );
    }
    else {
        return "";
    }

    switch( action() ) {
    case Unknown:
        // we do not report on this recipient.
        return "";
        break;
    case Failed:
        s = "Your message could not be delivered to ";
        s.append( a );
        s.append( "." );
        if ( !status().isEmpty() &&
             !remoteMTA().isEmpty() ) {
            s.append( " " );
            if ( lastAttempt() ) {
                s.append( "At " );
                s.append( lastAttempt()->isoDate() );
                s.append( ", " );
                s.append( lastAttempt()->isoTime() );
                s.append( ", the " );
            }
            else {
                s.append( "The " );
            }
            s.append( "next-hop server (" );
            s.append( remoteMTA() );
            s.append( ") returned the following error code: " );
            s.append( status() );
            s.append( ". This is a fatal error. Sorry." );
        }
        break;
    case Delayed:
        s = "Delivery to ";
        s.append( a );
        s.append( " is unexpectedly delayed. Delivery attempts continue." );
        // here, we want to say "the next attempt is in 25 minutes" or
        // words to that effect. Maybe we need setNextAttempt()?
        break;
    case Delivered:
        s = "Your message was delivered to ";
        s.append( a );
        s.append( "." );
        break;
    case Relayed:
        s = "While delivering to ";
            s.append( a );
        s.append( ", your message was forwarded to " );
        if ( !remoteMTA().isEmpty() ) {
            s.append( remoteMTA() );
            s.append( "," );
        }
        else {
            s.append( "a host" );
        }
        s.append( " which cannot send reports such as this one."
                  " Unless you receive an error report, you can assume"
                  " that your message arrived safely." );
        break;
    case Expanded:
        s = "Your message was delivered to ";
        s.append( a );
        s.append( ", and resent to several other addresses from there." );
        break;
    }

    return s;
}