00001 #include "mailerthread.h" 00002 #include "mailsender.h" 00003 00004 MailerThread::MailerThread(QObject *parent) : QThread(parent) 00005 { 00006 mail = new MailSender("smtp.gmail.com", "allevo.bugs@gmail.com", QStringList("allevo-bugs@lists.sourceforge.net"), "", ""); 00007 mail->setLogin("allevo.bugs", "allevobugs"); 00008 mail->setPort(587); 00009 00010 mail->setSsl(true); 00011 mail->setEncoding(MailSender::_8bit); 00012 mail->setISO(MailSender::utf8); 00013 mail->setContentType(MailSender::text); 00014 mail->setPriority(MailSender::high); 00015 } 00016 00017 void MailerThread::setMessage(const QString &text) 00018 { 00019 if(text != "") 00020 { 00021 mail->setBody(text); 00022 } 00023 else 00024 { 00025 mail->setBody("<html><header></header><body><H1>Empty Allevo Bugreport</H1></body></html>"); 00026 } 00027 } 00028 00029 void MailerThread::setSubject(const QString &subject) 00030 { 00031 if(subject != "") 00032 { 00033 mail->setSubject(subject); 00034 } 00035 else 00036 { 00037 mail->setSubject("Allevo Bugreport"); 00038 } 00039 } 00040 00041 void MailerThread::setAttachement(const QString &path) 00042 { 00043 if(path != "") 00044 { 00045 mail->setAttachments(QStringList(path)); 00046 } 00047 } 00048 00049 void MailerThread::setCc(const QString &cc) 00050 { 00051 if(cc != "") 00052 { 00053 mail->setCc(QStringList(cc)); 00054 } 00055 } 00056 00057 void MailerThread::run() 00058 { 00059 if(mail->send()) 00060 { 00061 emit mailSent(); 00062 } 00063 else 00064 { 00065 QString message = mail->lastError(); 00066 message += "\r\n"; 00067 message += mail->lastCmd(); 00068 message += "\r\n"; 00069 message += mail->lastResponse(); 00070 emit sendMailError(message); 00071 } 00072 }