summaryrefslogtreecommitdiff
path: root/noncore/net/mailit/emailhandler.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/mailit/emailhandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/emailhandler.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index 03f8a28..f6c6d60 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -179,55 +179,61 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
pos++;
if (p.separatorAt(pos) == ' ') {
mail->from = p.getString(&pos, '<', false);
mail->from = mail->from.stripWhiteSpace();
if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
mail->from = mail->from.left(mail->from.length() - 1);
mail->from = mail->from.right(mail->from.length() - 1);
}
pos++;
mail->fromMail = p.getString(&pos, '>', false);
} else {
if ((p.separatorAt(pos) == '<')
|| (p.separatorAt(pos) == ' ')) //No name.. nasty
pos++;
pos++;
mail->fromMail = p.getString(&pos, 'z', TRUE);
if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
mail->fromMail.truncate(mail->fromMail.length() - 1);
mail->from=mail->fromMail;
}
}
//@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To:
- if (pos = p.find("TO",':', pos, TRUE) != -1)
+ if ((pos = p.find("TO",':', 0, TRUE)) != -1)
{
pos++;
mail->recipients.append (p.getString(&pos, 'z', TRUE) );
}
-
+ //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To:
+ if ((pos = p.find("CC",':', 0, TRUE)) != -1)
+ {
+ pos++;
+ mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
+ }
+
if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
pos++;
mail->subject = p.getString(&pos, 'z', TRUE);
}
if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
pos++;
mail->date = p.getString(&pos, 'z', true);
}
if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
pos++;
if ( (p.wordAt(pos).upper() == "ID") &&
(p.separatorAt(pos) == ':') ) {
id = p.getString(&pos, 'z', TRUE);
mail->id = id;
}
}
pos = 0;
while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
@@ -413,48 +419,55 @@ int EmailHandler::parse64base(char *src, char *bufOut) {
bufOut[2] <<= 6;
z = li[3];
bufOut[2] = bufOut[2] | z; //third byte retrieved
processed++;
}
}
return processed;
}
int EmailHandler::encodeMime(Email *mail)
{
QString fileName, fileType, contentType, newBody, boundary;
Enclosure *ePtr;
QString userName = mailAccount.name;
if (userName.length()>0) //only embrace it if there is a user name
userName += " <" + mailAccount.emailAddress + ">";
//add standard headers
newBody = "From: " + userName + "\r\nTo: ";
for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) {
newBody += *it + " ";
}
+
+ newBody += "\r\nCC: ";
+
+ for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) {
+ newBody += *it + " ";
+ }
+
newBody += "\r\nSubject: " + mail->subject + "\r\n";
if (mail->files.count() == 0) { //just a simple mail
newBody += "\r\n" + mail->body;
mail->rawMail = newBody;
return 0;
}
//Build mime encoded mail
boundary = "-----4345=next_bound=0495----";
newBody += "Mime-Version: 1.0\r\n";
newBody += "Content-Type: multipart/mixed; boundary=\"" +
boundary + "\"\r\n\r\n";
newBody += "This is a multipart message in Mime 1.0 format\r\n\r\n";
newBody += "--" + boundary + "\r\nContent-Type: text/plain\r\n\r\n";
newBody += mail->body;
for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
fileName = ePtr->originalName;
fileType = ePtr->contentType;
QFileInfo fi(fileName);