Пример #1
0
EString DSN::dsnBody() const
{
    EString r;
    // [ original-envelope-id-field CRLF ]
    if ( !envelopeId().isEmpty() )
        r.append( "Original-Envelope-Id: " + envelopeId() + "\r\n" );

    // reporting-mta-field CRLF
    r.append( "Reporting-Mta: dns;" + Configuration::hostname() + "\r\n" );

    // [ received-from-mta-field CRLF ]
    if ( !receivedFrom().isEmpty() )
        r.append( "Received-From-Mta: dns;" + receivedFrom() + "\r\n" );

    // [ arrival-date-field CRLF ]
    if ( arrivalDate() )
        r.append( "Arrival-Date: " + arrivalDate()->rfc822() + "\r\n" );

    List<Recipient>::Iterator i( recipients() );
    while ( i ) {
        r.append( "\r\n" );
        r.append( i->dsnParagraph().wrapped( 72, "", "", true ).crlf() );
        ++i;
    }
    return r;
}
Пример #2
0
bool DSN::allFailed() const
{
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        if ( recipient->action() != Recipient::Failed )
            return false;
        ++recipient;
    }
    return true;
}
Пример #3
0
bool DSN::deliveriesPending() const
{
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        if ( recipient->action() == Recipient::Unknown ||
             recipient->action() == Recipient::Delayed )
            return true;
        ++recipient;
    }
    return false;
}
Пример #4
0
void
ShareDialog::accept()
{
    QStringList recipients( ui->recipients->items() );
    QString const message = ui->message->toPlainText();
    bool isPublic = ui->isPublic->isChecked();

    // disable the dialog until we get a response from Lasm_track.fm
    setEnabled( false );
    connect( m_track.share( recipients, message, isPublic ), SIGNAL(finished()), SLOT(onShared()) );
}
Пример #5
0
bool DSN::allOk() const
{
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        if ( recipient->action() != Recipient::Delivered &&
             recipient->action() != Recipient::Relayed &&
             recipient->action() != Recipient::Expanded )
            return false;
        ++recipient;
    }
    return true;
}
Пример #6
0
bool DSN::valid() const
{
    List<Recipient>::Iterator i( recipients() );
    while ( i ) {
        if ( !i->valid() )
            return false;
        ++i;
    }
    if ( !message() )
        return false;
    // anything else?
    return true;
}
Пример #7
0
EString DSN::plainBody() const
{
    EString r;
    List<Recipient>::Iterator recipient( recipients() );
    while ( recipient ) {
        EString tmp = recipient->plainTextParagraph();
        if ( !tmp.isEmpty() ) {
            r.append( tmp.wrapped( 72, "", "", true ).crlf() );
            r.append( "\r\n" );
        }
        ++recipient;
    }

    // this code sneakily ensures that the ideal line wrap point is
    // just before the server name, almost independent of the server
    // name's length. fine for testing.
    r.append( "This message was generated by Archiveopteryx " );
    r.append( Configuration::compiledIn( Configuration::Version ) );
    r.append( ", running on mail server \r\n" );
    r.append( Configuration::hostname() );
    r.append( ".\r\n" );

    if ( arrivalDate() && !receivedFrom().isEmpty() ) {
        EString tmp = "\nThe message arrived at ";
        tmp.append( arrivalDate()->isoDate() );
        tmp.append( ", " );
        tmp.append( arrivalDate()->isoTime() );
        tmp.append( " from host " );
        tmp.append( receivedFrom() );
        tmp.append( "." );
        r.append( tmp.wrapped( 72, "", "", true ).crlf() );
    }
    else if ( arrivalDate() ) {
        EString tmp = "\nThe message arrived at ";
        tmp.append( arrivalDate()->isoDate() );
        tmp.append( "." );
        r.append( tmp.wrapped( 72, "", "", true ).crlf() );
    }
    else if ( !receivedFrom().isEmpty() ) {
        EString tmp = "\nThe message was received from host ";
        tmp.append( receivedFrom() );
        tmp.append( "." );
        r.append( tmp.wrapped( 72, "", "", true ).crlf() );
    }

    return r;
}
Пример #8
0
int CSendMail::SendMail(const CString& FromName, const CString& FromMail, const CString& To, const CString& CC, const CString& subject, const CString& body, CStringArray &attachments, CString *errortext)
{
	if (CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\DeliveryType"), SEND_MAIL_MAPI) == SEND_MAIL_MAPI)
	{
		CMailMsg mapiSender;
		BOOL bMAPIInit = mapiSender.MAPIInitialize();
		if (!bMAPIInit)
		{
			if (errortext)
				*errortext = mapiSender.GetLastErrorMsg();
			return -1;
		}

		mapiSender.SetShowComposeDialog(TRUE);
		mapiSender.SetFrom(FromMail, FromName);
		mapiSender.SetTo(To);
		if (!CC.IsEmpty())
			mapiSender.SetCC(CC);
		mapiSender.SetSubject(subject);
		mapiSender.SetMessage(body);
		for (int i = 0; i < attachments.GetSize(); ++i)
			mapiSender.AddAttachment(attachments[i]);

		BOOL bSend = mapiSender.Send();
		if (bSend == TRUE)
			return 0;
		else
		{
			if (errortext)
				*errortext = mapiSender.GetLastErrorMsg();
			return -1;
		}
	}
	else
	{
		CString sender;
		sender.Format(_T("%s <%s>"), (LPCTSTR)FromName, (LPCTSTR)FromMail);

		CHwSMTP mail;
		if (CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\DeliveryType"), SEND_MAIL_SMTP_CONFIGURED) == SEND_MAIL_SMTP_CONFIGURED)
		{
			CString recipients(To);
			if (!CC.IsEmpty())
				recipients += L";" + CC;
			if (mail.SendEmail((CString)CRegString(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\Address"), _T("")), (CString)CRegString(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\Username"), _T("")), (CString)CRegString(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\Password"), _T("")), (BOOL)CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\AuthenticationRequired"), FALSE), sender, recipients, subject, body, nullptr, &attachments, CC, (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\Port"), 25), sender, To, (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\Encryption"), 0)) == TRUE)
				return 0;
			else
			{
				if (errortext)
					*errortext = mail.GetLastErrorText();
				return -1;
			}
		}
		else if (mail.SendSpeedEmail(sender, To, subject, body, nullptr, &attachments, CC, sender))
			return 0;
		else
		{
			if (errortext)
				*errortext = mail.GetLastErrorText();
			return -1;
		}
	}
}