diff --git a/src/include/utility.cpp b/src/include/utility.cpp index 7516a6dca..2b264e1f1 100755 --- a/src/include/utility.cpp +++ b/src/include/utility.cpp @@ -900,22 +900,28 @@ void split_IBAN(const char * iban, TString & iso, TString & cin, } } +static TString __test_mail("void"); + +void set_test_mail(const TString & email) +{ + if (email.full()) + __test_mail = email; + else + __test_mail = ini_get_string(CONFIG_STUDIO, "Mail", "TestMail"); +} + bool send_mail(TToken_string & to, TToken_string & cc, TToken_string & ccn, - const char * subj, const char * text, TToken_string & attachment) + const char * subj, const char * text, TToken_string & attachment, bool ui, bool receipt) { TString subject(subj); - short flags = 0; // not UI + short flags = ui ? 1 : 0; -#ifdef DBG - TString test_mail = ini_get_string(CONFIG_STUDIO, "Mail", "TestMail"); - - if (test_mail.full()) - { - to = test_mail; - cc.cut(0); - ccn.cut(0); - } -#endif + if (receipt) + flags |= 0x2; + if (__test_mail == "void") + set_test_mail(EMPTY_STRING); + if (__test_mail.full()) + to = __test_mail; if (subject.blank()) subject.cut(0) << TR("Invio di ") << attachment; if (!(flags & 0x1) && to.empty_items() && cc.empty_items() && ccn.empty_items()) diff --git a/src/include/utility.h b/src/include/utility.h index 0dfbcb9b8..35ca3323f 100755 --- a/src/include/utility.h +++ b/src/include/utility.h @@ -118,7 +118,8 @@ void build_IBAN(TString & iban, const char * iso, const char * icin, void split_IBAN(const char * iban, TString & iso, TString & icin, TString & bcin, TString & abi, TString & cab, TString & cc); +void set_test_mail(const TString & email); bool send_mail(TToken_string & to, TToken_string & cc, TToken_string & ccn, - const char * subj, const char * text, TToken_string & attachment); + const char * subj, const char * text, TToken_string & attachment, bool ui, bool receipt); #endif /* __UTILITY_H */