summaryrefslogtreecommitdiff
path: root/noncore/net/mail/smtpwrapper.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/mail/smtpwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/smtpwrapper.cpp61
1 files changed, 51 insertions, 10 deletions
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp
index 162b1b9..a6a46ba 100644
--- a/noncore/net/mail/smtpwrapper.cpp
+++ b/noncore/net/mail/smtpwrapper.cpp
@@ -8,3 +8,4 @@
-#include <libetpan/mailmime.h>
+#include <libetpan/libetpan.h>
+#if 0
#include <libetpan/mailimf.h>
@@ -13,2 +14,3 @@
#include <libetpan/maildriver.h>
+#endif
@@ -16,2 +18,3 @@
#include "mailwrapper.h"
+#include "mboxwrapper.h"
#include "logindialog.h"
@@ -467,2 +470,19 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size )
{
+
+ QFile msg_cache(file);
+ QString msg = "";
+ msg_cache.open(IO_ReadOnly);
+ char*message = new char[4096];
+ memset(message,0,4096);
+ while (msg_cache.readBlock(message,4095)>0) {
+ msg+=message;
+ memset(message,0,4096);
+ }
+ delete message;
+ *data = (char*)malloc(msg.length()+1*sizeof(char));
+ memset(*data,0,msg.length()+1);
+ memcpy(*data,msg.ascii(),msg.length());
+ *size=msg.length();
+
+#if 0
char *buf;
@@ -497,2 +517,3 @@ err_close:
close( fd );
+#endif
}
@@ -504,3 +525,12 @@ void SMTPwrapper::progress( size_t current, size_t maximum )
-void SMTPwrapper::smtpSend( mailmime *mail )
+void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
+{
+ if (!mail) return;
+ QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
+ MBOXwrapper*wrap = new MBOXwrapper(localfolders);
+ wrap->storeMessage(mail,length,box);
+ delete wrap;
+}
+
+void SMTPwrapper::smtpSend( mailmime *mail,bool later )
{
@@ -521,5 +551,2 @@ void SMTPwrapper::smtpSend( mailmime *mail )
}
- server = strdup( smtp->getServer().latin1() );
- ssl = smtp->getSSL();
- port = smtp->getPort().toUInt();
rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
@@ -528,2 +555,3 @@ void SMTPwrapper::smtpSend( mailmime *mail )
writeToFile( file, mail );
+
readFromFile( file, &data, &size );
@@ -531,3 +559,15 @@ void SMTPwrapper::smtpSend( mailmime *mail )
f.remove();
+
+ storeMail(data,size,(later?"Outgoing":"Sent"));
+ if (later) {
+ smtp_address_list_free( rcpts );
+ if (data) free( data );
+ if (from) free(from);
+ return;
+ }
+ server = strdup( smtp->getServer().latin1() );
+ ssl = smtp->getSSL();
+ port = smtp->getPort().toUInt();
+
session = mailsmtp_new( 20, &progress );
@@ -583,4 +623,5 @@ free_mem:
smtp_address_list_free( rcpts );
- free( data );
- free( server );
+ if (data) free( data );
+ if (from) free(from);
+ if (server) free( server );
if ( smtp->getLogin() ) {
@@ -592,5 +633,5 @@ free_mem:
-void SMTPwrapper::sendMail(const Mail&mail )
+void SMTPwrapper::sendMail(const Mail&mail,bool later )
{
- mailmime *mimeMail;
+ mailmime * mimeMail;
@@ -600,3 +641,3 @@ void SMTPwrapper::sendMail(const Mail&mail )
} else {
- smtpSend( mimeMail );
+ smtpSend( mimeMail,later );
mailmime_free( mimeMail );