Index: /AE/RequestHelp/src/_Version.h
===================================================================
--- /AE/RequestHelp/src/_Version.h	(revision 1005)
+++ /AE/RequestHelp/src/_Version.h	(revision 1005)
@@ -0,0 +1,11 @@
+#ifndef _VERSION_H 
+#define _VERSION_H
+
+#define STRINGIZE2(s) #s
+#define STRINGIZE(s) STRINGIZE2(s)
+
+#define REQHELP_VERSION_MAJOR 1
+#define REQHELP_VERSION_MINOR 0
+#define REQHELP_VERSION_STRING STRINGIZE(REQHELP_VERSION_MAJOR) "." STRINGIZE(REQHELP_VERSION_MINOR)
+
+#endif
Index: /AE/RequestHelp/src/_VersionInfo.rc
===================================================================
--- /AE/RequestHelp/src/_VersionInfo.rc	(revision 1005)
+++ /AE/RequestHelp/src/_VersionInfo.rc	(revision 1005)
@@ -0,0 +1,30 @@
+#include "_Version.h"
+1 VERSIONINFO
+ FILEVERSION REQHELP_VERSION_MAJOR,REQHELP_VERSION_MINOR,0,0
+ PRODUCTVERSION REQHELP_VERSION_MAJOR,REQHELP_VERSION_MINOR,0,0
+ FILEFLAGSMASK 0x17L
+ FILEFLAGS 0x0L
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "080904b0"
+        BEGIN
+            VALUE "Comments", "Request help for installation of AE."
+            VALUE "CompanyName", "oni2.net"
+            VALUE "FileDescription", "Request help for installation of AE."
+            VALUE "FileVersion", REQHELP_VERSION_STRING
+            VALUE "InternalName", "RequestHelp"
+            VALUE "LegalCopyright", "©2014 oni2.net"
+            VALUE "OriginalFilename", "RequestHelp.exe"
+            VALUE "ProductName", "Request Help"
+            VALUE "ProductVersion", REQHELP_VERSION_STRING
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x809, 1200
+    END
+END
Index: /AE/RequestHelp/src/mailFromGui.c
===================================================================
--- /AE/RequestHelp/src/mailFromGui.c	(revision 1005)
+++ /AE/RequestHelp/src/mailFromGui.c	(revision 1005)
@@ -0,0 +1,191 @@
+#include "mailFromGui.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+
+#define WIN_WIDTH  450
+#define WIN_HEIGHT 270
+
+enum {
+	TXT_INFO,
+	TXT_MAIL,
+	EDIT_MAIL,
+	CHK_CC,
+	BTN_SEND,
+	BTN_ABORT
+} window_objects;
+
+bool isSendSelected = false;
+bool isCCSelected = false;
+char* emailFrom = 0;
+
+static HWND hwndEditMail;
+
+static bool verifyMail() {
+	char* at = strchr(emailFrom, '@');
+	char* dot = strrchr(emailFrom, '.');
+	if (at == NULL || dot == NULL)
+		return false;
+	if (dot <= at)
+		return false;
+
+	unsigned int atPos = at - emailFrom;
+	unsigned int dotPos = dot - emailFrom;
+	if (atPos < 1 || (dotPos - atPos) < 2)
+		return false;
+	if (dotPos >= strlen(emailFrom)-1)
+		return false;
+
+	return true;
+}
+
+static void handleWindowCreate(HWND hwnd) {
+	static LPCSTR txtInfo = "\
+With this program you can request help from the AE\n\
+support team if you have trouble installing the AE.\n\
+\n\
+Please only use this if you are asked to on the forum!\n\
+\n\
+The information that is sent is:\n\
+- AEI updater's updater_output.log\n\
+- AEI-ProxySettings.xml\n\
+- A list of files within your AE/ folder";
+
+	int top = 0, left = 5;
+	int height, width = WIN_WIDTH - 2*left - 4;
+
+	top += 5;
+	height = 150;
+	CreateWindowA("STATIC", txtInfo, 
+		WS_CHILD | WS_VISIBLE | SS_LEFT,
+		left, top, width, height,
+		hwnd, (HMENU) TXT_INFO, NULL, NULL);
+
+	top += height + 5;
+	height = 20;
+	width = 145;
+	CreateWindowA("STATIC", "Your e-mail address:", 
+		WS_CHILD | WS_VISIBLE | SS_LEFT,
+		left, top, width, height,
+		hwnd, (HMENU) TXT_MAIL, NULL, NULL);
+	left += width + 5;
+	width = WIN_WIDTH - 20 - width;
+	hwndEditMail = CreateWindowA("Edit", NULL, 
+		WS_CHILD | WS_VISIBLE | WS_BORDER,
+		left, top, width, height, hwnd, (HMENU) EDIT_MAIL,
+		NULL, NULL);
+	left = 5;
+	width = WIN_WIDTH - 2*left - 4;
+
+	top += height + 5;
+	height = 20;
+	CreateWindowA("button", "Send a copy of the mail to you",
+		WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
+		left, top, width, height, hwnd, (HMENU) CHK_CC, 
+		NULL, NULL);
+
+	top += height + 5;
+	height = 28;
+	width = 100;
+	left = WIN_WIDTH - 3*5 - 2*width;
+	CreateWindowA("button", "Send request",
+		WS_VISIBLE | WS_CHILD ,
+		left, top, width, height,
+		hwnd, (HMENU) BTN_SEND, NULL, NULL);
+	left = WIN_WIDTH - 2*5 - 1*width;
+	CreateWindowA("button", "Abort",
+		WS_VISIBLE | WS_CHILD ,
+		left, top, width, height,
+		hwnd, (HMENU) BTN_ABORT, NULL, NULL);
+}
+
+static void handleWindowCommand(HWND hwnd, WPARAM wParam) {
+	bool checked;
+	int len;
+	
+	switch (LOWORD(wParam)) {
+		case BTN_SEND:
+			len = GetWindowTextLengthA(hwndEditMail) + 1;
+			emailFrom = malloc(len);
+			GetWindowTextA(hwndEditMail, emailFrom, len);
+
+			if (verifyMail()) {
+				isSendSelected = true;
+				ShowWindow(hwnd, SW_HIDE);
+				PostQuitMessage(0);
+			} else {
+				MessageBox(hwnd, "Please enter a valid e-mail address", "Invalid e-mail", MB_OK | MB_ICONEXCLAMATION);
+			}
+			break;
+		case BTN_ABORT:
+			PostQuitMessage(0);
+			break;
+		case CHK_CC:
+			checked = IsDlgButtonChecked(hwnd, CHK_CC);
+			if (checked) {
+				CheckDlgButton(hwnd, CHK_CC, BST_UNCHECKED);
+				isCCSelected = false;
+			} else {
+				CheckDlgButton(hwnd, CHK_CC, BST_CHECKED);
+				isCCSelected = true;
+			}
+			break;
+	}
+}
+
+static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	switch(msg)
+	{
+		case WM_CREATE:
+			handleWindowCreate(hwnd);
+			break;
+
+		case WM_COMMAND:
+			handleWindowCommand(hwnd, wParam);
+			break;
+
+		case WM_DESTROY:
+			PostQuitMessage(0);
+			return 0;      
+	}
+
+	return DefWindowProcW(hwnd, msg, wParam, lParam);
+}
+
+
+void mailFromGui(HMODULE hInstance, int nCmdShow)
+{
+	static const LPCWSTR title = L"Request Help";
+
+	MSG  msg;    
+	HWND hwnd;
+	WNDCLASSW wc;
+
+	wc.style         = CS_HREDRAW | CS_VREDRAW;
+	wc.cbClsExtra    = 0;
+	wc.cbWndExtra    = 0;
+	wc.lpszClassName = L"Window";
+	wc.hInstance     = hInstance;
+	wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
+	wc.lpszMenuName  = NULL;
+	wc.lpfnWndProc   = WndProc;
+	wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
+	wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
+
+	RegisterClassW(&wc);
+	hwnd = CreateWindowW( wc.lpszClassName, title,
+		WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_VISIBLE,
+		CW_USEDEFAULT, CW_USEDEFAULT, WIN_WIDTH, WIN_HEIGHT, NULL, NULL, hInstance, NULL);  
+
+	ShowWindow(hwnd, nCmdShow);
+	UpdateWindow(hwnd);
+
+	while( GetMessage(&msg, NULL, 0, 0)) {
+		TranslateMessage(&msg);
+		DispatchMessage(&msg);
+	}
+}
+
Index: /AE/RequestHelp/src/mailFromGui.h
===================================================================
--- /AE/RequestHelp/src/mailFromGui.h	(revision 1005)
+++ /AE/RequestHelp/src/mailFromGui.h	(revision 1005)
@@ -0,0 +1,14 @@
+#ifndef _MAILFROMGUI_H_
+#define _MAILFROMGUI_H_
+
+#include <windows.h>
+#include <stdbool.h>
+
+void mailFromGui(HMODULE hInstance, int nCmdShow);
+
+extern bool isSendSelected;
+extern bool isCCSelected;
+extern char* emailFrom;
+
+
+#endif
Index: /AE/RequestHelp/src/main.c
===================================================================
--- /AE/RequestHelp/src/main.c	(revision 1005)
+++ /AE/RequestHelp/src/main.c	(revision 1005)
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include "quickmail.h"
+#include "mailFromGui.h"
+
+#define TO          "ae-support@oni2.net"
+#define SMTPSERVER  "mail.illy.bz"
+#define SUBJECT     "AE support request"
+#define SMTPPORT    25
+#define SMTPUSER    NULL
+#define SMTPPASS    NULL
+
+static void appendString(char** buffer, unsigned int* bufsize, char* append) {
+	if ((strlen(*buffer) + strlen(append) + 2) >= *bufsize) {
+		unsigned int addon = (strlen(append) > 500 ? strlen(append)+500 : 500);
+		*bufsize += addon;
+
+		char* temp = malloc(*bufsize);
+		
+		strcpy(temp, *buffer);
+
+		free(*buffer);
+		*buffer = temp;
+	}
+	strcat(*buffer, append);
+}
+
+static char* buildDirectoryListing(char* path, int level) {
+	unsigned int bufsize = 500;
+	char* strbuf = malloc(bufsize);
+	strbuf[0] = 0;
+	
+	if (level >= 4)
+		return strbuf;
+	
+	struct dirent *dp;
+	DIR *dfd = opendir(path);
+	if(dfd != NULL) {
+		while((dp = readdir(dfd)) != NULL) {
+			if (strcmp(".", dp->d_name) != 0 && strcmp("..", dp->d_name) != 0) {
+				char* name = malloc(strlen(path) + strlen(dp->d_name) + 2);
+				sprintf(name, "%s/%s", path, dp->d_name);
+
+				appendString(&strbuf, &bufsize, name);
+				strcat(strbuf, "\n");
+				
+				//printf("%2d: %s\n", level, name);
+
+				char* sub = buildDirectoryListing(name, level+1);
+				appendString(&strbuf, &bufsize, sub);
+			}
+		}
+		closedir(dfd);
+	}
+	return strbuf;
+}
+
+static void sendMail() {
+	char message[500] = "";
+	
+	quickmail_initialize();
+	quickmail mailobj = quickmail_create(emailFrom, SUBJECT);
+	quickmail_add_to(mailobj, TO);
+	if (isCCSelected) {
+		quickmail_add_cc(mailobj, emailFrom);
+	}
+	
+	if (access("AEInstaller/updater_output.log", F_OK) != 0) {
+		strcat(message, "updater_output.log does not exist!\n");
+	}
+	if (access("AEInstaller/AEI-ProxySettings.xml", F_OK) != 0) {
+		strcat(message, "AEI-ProxySettings.xml does not exist!\n");
+	}
+
+	
+	quickmail_set_body(mailobj, message);
+	
+	quickmail_add_attachment_file(mailobj, "AEInstaller/updater_output.log", "text/plain");
+	quickmail_add_attachment_file(mailobj, "AEInstaller/AEI-ProxySettings.xml", "text/xml");
+	
+	char* dirList = buildDirectoryListing(".", 0);
+	quickmail_add_attachment_memory(mailobj, "DirListing.txt", "text/plain", dirList, strlen(dirList)+1, 1);
+
+	const char* errmsg;
+	quickmail_set_debug_log(mailobj, stderr);
+	if ((errmsg = quickmail_send(mailobj, SMTPSERVER, SMTPPORT, SMTPUSER, SMTPPASS)) != NULL)
+		fprintf(stderr, "Error sending e-mail: %s\n", errmsg);
+	quickmail_destroy(mailobj);
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+	if (access("AEInstaller/", F_OK) != 0 || access("AEInstaller/AEInstaller2Updater.jar", F_OK) != 0) {
+		MessageBox(NULL,
+				"Please put this program in your Oni/AE folder!",
+				"Invalid location",
+				MB_OK | MB_ICONERROR);
+	} else {
+		mailFromGui(hInstance, nShowCmd);
+	
+		if (isSendSelected)
+			sendMail();
+	}
+	
+	return EXIT_SUCCESS;
+}
+
Index: /AE/RequestHelp/src/makefile
===================================================================
--- /AE/RequestHelp/src/makefile	(revision 1005)
+++ /AE/RequestHelp/src/makefile	(revision 1005)
@@ -0,0 +1,58 @@
+# If SRC or TARGET is a folder it must end in a slash "/"
+SRC = 
+TARGET = ../build/
+SUBFOLDERS = quickmail
+
+DEF = NOCURL STATIC
+INCLUDEPATHS = . ./quickmail
+GCCFLAGS = -std=c99 -O0 -Wall -fomit-frame-pointer -fpack-struct -Wextra -Wno-pragmas -Wno-unused-variable $(addprefix -I,$(INCLUDEPATHS)) -Wno-unused-parameter $(addprefix -D,$(DEF))
+LINKFLAGS = -Os -Wall
+LOCALE = LC_MESSAGES=C
+
+LIBDIRS = 
+LIBS = -lwsock32
+#-lgdi32
+OUT = $(TARGET)RequestHelp.exe
+
+FILES := _VersionInfo.rc $(foreach dir,. $(SUBFOLDERS),$(wildcard $(SRC)$(dir)/*.c))
+
+###################################################
+#                                                 #
+# Should not be required to change anything below #
+#                                                 #
+###################################################
+
+UNAME := $(shell uname -s)
+ifeq ("Linux","$(UNAME)")
+    GCC := i686-w64-mingw32-gcc
+    WINDRES := i686-w64-mingw32-windres
+else
+    GCC := gcc
+    WINDRES := windres
+endif
+
+DESTFOLDERS = $(addprefix $(TARGET),$(SUBFOLDERS))
+DEST = $(patsubst $(SRC)%.rc,$(TARGET)%.o,$(patsubst $(SRC)%.c,$(TARGET)%.o,$(FILES)))
+
+ALL: $(DESTFOLDERS) $(DEST) $(OBJS)
+	@echo "Linking"
+	$(LOCALE) $(GCC) $(LINKFLAGS) -o $(OUT) $(DEST) $(OBJS) $(LIBDIRS) $(LIBS)
+
+clean:
+	rm -f $(DEST)
+	rm -Rf $(DESTFOLDERS)
+	rm -f $(OUT)
+
+$(DESTFOLDERS):
+	mkdir -p $@
+
+$(TARGET)%.o: $(SRC)%.c
+	@echo "Compiling $<"
+	$(LOCALE) $(GCC) $(GCCFLAGS) -c -o $@ $<
+	@echo
+
+$(TARGET)%.o: $(SRC)%.rc
+	@echo "Assembling resource $<"
+	$(WINDRES) -i $< -o $@
+	@echo
+
Index: /AE/RequestHelp/src/quickmail/License.txt
===================================================================
--- /AE/RequestHelp/src/quickmail/License.txt	(revision 1005)
+++ /AE/RequestHelp/src/quickmail/License.txt	(revision 1005)
@@ -0,0 +1,19 @@
+libquickmail - a library for sending e-mails
+Copyright (C) 2012-2013 Brecht Sanders
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+If you would like to negotiate alternate licensing terms, you may do
+so by contacting: Brecht Sanders <brechtsanders@users.sourceforge.net>
Index: /AE/RequestHelp/src/quickmail/README
===================================================================
--- /AE/RequestHelp/src/quickmail/README	(revision 1005)
+++ /AE/RequestHelp/src/quickmail/README	(revision 1005)
@@ -0,0 +1,17 @@
+Project name:
+	libquickmail
+URL:
+	http://sourceforge.net/projects/libquickmail/
+Project discription:
+	C library intended to give C/C++ developers a quick and easy way
+	to send e-mail from their applications.
+	For the actual SMTP communication this library depends on libcurl.
+	There is also a light version available without libcurl dependancy.
+	The library can also be used to just create a multipart MIME
+	message body.
+	Features:
+	- multiple To/Cc/Bcc recipients
+	- multiple attachments without size limitation
+	- multiple bodies in alternative formats (e.g: text + HTML)
+	- SMTP authentication
+	- TLS encryption (via libcurl)
Index: /AE/RequestHelp/src/quickmail/quickmail.c
===================================================================
--- /AE/RequestHelp/src/quickmail/quickmail.c	(revision 1005)
+++ /AE/RequestHelp/src/quickmail/quickmail.c	(revision 1005)
@@ -0,0 +1,1121 @@
+/*
+    This file is part of libquickmail.
+
+    libquickmail is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    libquickmail is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with libquickmail.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#if defined(_WIN32) && defined(DLL_EXPORT) && !defined(BUILD_QUICKMAIL_DLL)
+#define BUILD_QUICKMAIL_DLL
+#endif
+#include "quickmail.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#if _MSC_VER
+#define snprintf _snprintf
+#define strdup _strdup
+#endif
+#ifndef NOCURL
+#if (defined(STATIC) || defined(BUILD_QUICKMAIL_STATIC)) && !defined(CURL_STATICLIB)
+#define CURL_STATICLIB
+#endif
+#include <curl/curl.h>
+#else
+#include "smtpsocket.h"
+#endif
+
+#define LIBQUICKMAIL_VERSION_MAJOR 0
+#define LIBQUICKMAIL_VERSION_MINOR 1
+#define LIBQUICKMAIL_VERSION_MICRO 18
+
+#define VERSION_STRINGIZE_(major, minor, micro) #major"."#minor"."#micro
+#define VERSION_STRINGIZE(major, minor, micro) VERSION_STRINGIZE_(major, minor, micro)
+
+#define LIBQUICKMAIL_VERSION VERSION_STRINGIZE(LIBQUICKMAIL_VERSION_MAJOR,LIBQUICKMAIL_VERSION_MINOR,LIBQUICKMAIL_VERSION_MICRO)
+
+#define NEWLINE "\r\n"
+#define NEWLINELENGTH 2
+//#define NEWLINE "\n"
+//#define NEWLINELENGTH 1
+
+#define MIME_LINE_WIDTH 72
+#define BODY_BUFFER_SIZE 256
+
+//definitions of the differen stages of generating the message data
+#define MAILPART_INITIALIZE 0
+#define MAILPART_HEADER     1
+#define MAILPART_BODY       2
+#define MAILPART_BODY_DONE  3
+#define MAILPART_ATTACHMENT 4
+#define MAILPART_END        5
+#define MAILPART_DONE       6
+
+static const char* default_mime_type = "text/plain";
+
+////////////////////////////////////////////////////////////////////////
+
+#define DEBUG_ERROR(errmsg)
+static const char* ERRMSG_MEMORY_ALLOCATION_ERROR = "Memory allocation error";
+
+////////////////////////////////////////////////////////////////////////
+
+char* randomize_zeros (char* data)
+{
+  //replace all 0s with random digits
+  char* p = data;
+  while (*p) {
+    if (*p == '0')
+      *p = '0' + rand() % 10;
+    p++;
+  }
+  return data;
+}
+
+char* str_append (char** data, const char* newdata)
+{
+  //append a string to the end of an existing string
+  char* p;
+  int len = (*data ? strlen(*data) : 0);
+  if ((p = (char*)realloc(*data, len + strlen(newdata) + 1)) == NULL) {
+    free(p);
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return NULL;
+  }
+  *data = p;
+  strcpy(*data + len, newdata);
+  return *data;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+struct email_info_struct {
+  int current;  //must be zet to 0
+  time_t timestamp;
+  char* from;
+  struct email_info_email_list_struct* to;
+  struct email_info_email_list_struct* cc;
+  struct email_info_email_list_struct* bcc;
+  char* subject;
+  char* header;
+  struct email_info_attachment_list_struct* bodylist;
+  struct email_info_attachment_list_struct* attachmentlist;
+  char* buf;
+  int buflen;
+  char* mime_boundary_body;
+  char* mime_boundary_part;
+  struct email_info_attachment_list_struct* current_attachment;
+  FILE* debuglog;
+  char dtable[64];
+};
+
+////////////////////////////////////////////////////////////////////////
+
+struct email_info_email_list_struct {
+  char* data;
+  struct email_info_email_list_struct* next;
+};
+
+void email_info_string_list_add (struct email_info_email_list_struct** list, const char* data)
+{
+  struct email_info_email_list_struct** p = list;
+  while (*p)
+    p = &(*p)->next;
+  if ((*p = (struct email_info_email_list_struct*)malloc(sizeof(struct email_info_email_list_struct))) == NULL) {
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return;
+  }
+  (*p)->data = (data ? strdup(data) : NULL);
+  (*p)->next = NULL;
+}
+
+void email_info_string_list_free (struct email_info_email_list_struct** list)
+{
+  struct email_info_email_list_struct* p = *list;
+  struct email_info_email_list_struct* current;
+  while (p) {
+    current = p;
+    p = current->next;
+    free(current->data);
+    free(current);
+  }
+  *list = NULL;
+}
+
+char* email_info_string_list_concatenate (struct email_info_email_list_struct* list)
+{
+  char* result = NULL;
+  struct email_info_email_list_struct* listentry = list;
+  while (listentry) {
+    if (listentry->data && *listentry->data) {
+      if (result)
+        str_append(&result, "," NEWLINE "\t");
+      str_append(&result, "<");
+      str_append(&result, listentry->data);
+      str_append(&result, ">");
+    }
+    listentry = listentry->next;
+  }
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////////
+
+struct email_info_attachment_list_struct {
+  char* filename;
+  char* mimetype;
+  void* filedata;
+  void* handle;
+  quickmail_attachment_open_fn email_info_attachment_open;
+  quickmail_attachment_read_fn email_info_attachment_read;
+  quickmail_attachment_close_fn email_info_attachment_close;
+  quickmail_attachment_free_filedata_fn email_info_attachment_filedata_free;
+  struct email_info_attachment_list_struct* next;
+};
+
+struct email_info_attachment_list_struct* email_info_attachment_list_add (struct email_info_attachment_list_struct** list, const char* filename, const char* mimetype, void* filedata, quickmail_attachment_open_fn email_info_attachment_open, quickmail_attachment_read_fn email_info_attachment_read, quickmail_attachment_close_fn email_info_attachment_close, quickmail_attachment_free_filedata_fn email_info_attachment_filedata_free)
+{
+  struct email_info_attachment_list_struct** p = list;
+  while (*p)
+    p = &(*p)->next;
+  if ((*p = (struct email_info_attachment_list_struct*)malloc(sizeof(struct email_info_attachment_list_struct))) == NULL) {
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return NULL;
+  }
+  (*p)->filename = strdup(filename ? filename : "UNNAMED");
+  (*p)->mimetype = (mimetype ? strdup(mimetype) : NULL);
+  (*p)->filedata = filedata;
+  (*p)->handle = NULL;
+  (*p)->email_info_attachment_open = email_info_attachment_open;
+  (*p)->email_info_attachment_read = email_info_attachment_read;
+  (*p)->email_info_attachment_close = email_info_attachment_close;
+  (*p)->email_info_attachment_filedata_free = email_info_attachment_filedata_free;
+  (*p)->next = NULL;
+  return *p;
+}
+
+void email_info_attachment_list_free_entry (struct email_info_attachment_list_struct* current)
+{
+  if (current->handle) {
+    if (current->email_info_attachment_close)
+      current->email_info_attachment_close(current->handle);
+    //else
+    //  free(current->handle);
+    current->handle = NULL;
+  }
+  if (current->filedata) {
+    if (current->email_info_attachment_filedata_free)
+      current->email_info_attachment_filedata_free(current->filedata);
+    else
+      free(current->filedata);
+  }
+  if (current->mimetype)
+    free(current->mimetype);
+  free(current->filename);
+  free(current);
+}
+
+void email_info_attachment_list_free (struct email_info_attachment_list_struct** list)
+{
+  struct email_info_attachment_list_struct* p = *list;
+  struct email_info_attachment_list_struct* current;
+  while (p) {
+    current = p;
+    p = current->next;
+    email_info_attachment_list_free_entry(current);
+  }
+  *list = NULL;
+}
+
+int email_info_attachment_list_delete (struct email_info_attachment_list_struct** list, const char* filename)
+{
+  struct email_info_attachment_list_struct** p = list;
+  while (*p) {
+    if (strcmp((*p)->filename, filename) == 0) {
+      struct email_info_attachment_list_struct* current = *p;
+      *p = current->next;
+      email_info_attachment_list_free_entry(current);
+      return 0;
+    }
+    p = &(*p)->next;
+  }
+  return -1;
+}
+
+void email_info_attachment_list_close_handles (struct email_info_attachment_list_struct* list)
+{
+  struct email_info_attachment_list_struct* p = list;
+  while (p) {
+    if (p->handle) {
+      if (p->email_info_attachment_close)
+        p->email_info_attachment_close(p->handle);
+      //else
+      //  free(p->handle);
+      p->handle = NULL;
+    }
+    p = p->next;
+  }
+}
+
+//dummy attachment functions
+
+void* email_info_attachment_open_dummy (void* filedata)
+{
+  return &email_info_attachment_open_dummy;
+}
+
+size_t email_info_attachment_read_dummy (void* handle, void* buf, size_t len)
+{
+  return 0;
+}
+
+struct email_info_attachment_list_struct* email_info_attachment_list_add_dummy (struct email_info_attachment_list_struct** list, const char* filename, const char* mimetype)
+{
+  return email_info_attachment_list_add(list, filename, mimetype, NULL, email_info_attachment_open_dummy, email_info_attachment_read_dummy, NULL, NULL);
+}
+
+//file attachment functions
+
+void* email_info_attachment_open_file (void* filedata)
+{
+  return (void*)fopen((char*)filedata, "rb");
+}
+
+size_t email_info_attachment_read_file (void* handle, void* buf, size_t len)
+{
+  return fread(buf, 1, len, (FILE*)handle);
+}
+
+void email_info_attachment_close_file (void* handle)
+{
+  if (handle)
+    fclose((FILE*)handle);
+}
+
+struct email_info_attachment_list_struct* email_info_attachment_list_add_file (struct email_info_attachment_list_struct** list, const char* path, const char* mimetype)
+{
+  //determine base filename
+  const char* basename = path + strlen(path);
+  while (basename != path) {
+    basename--;
+    if (*basename == '/'
+#ifdef _WIN32
+        || *basename == '\\' || *basename == ':'
+#endif
+    ) {
+      basename++;
+      break;
+    }
+  }
+  return email_info_attachment_list_add(list, basename, mimetype, (void*)strdup(path), email_info_attachment_open_file, email_info_attachment_read_file, email_info_attachment_close_file, NULL);
+}
+
+//memory attachment functions
+
+struct email_info_attachment_memory_filedata_struct {
+  char* data;
+  size_t datalen;
+  int mustfree;
+};
+
+struct email_info_attachment_memory_handle_struct {
+  const char* data;
+  size_t datalen;
+  size_t pos;
+};
+
+void* email_info_attachment_open_memory (void* filedata)
+{
+  struct email_info_attachment_memory_filedata_struct* data;
+  struct email_info_attachment_memory_handle_struct* result;
+  data = ((struct email_info_attachment_memory_filedata_struct*)filedata);
+  if (!data->data)
+    return NULL;
+  if ((result = (struct email_info_attachment_memory_handle_struct*)malloc(sizeof(struct email_info_attachment_memory_handle_struct))) == NULL) {
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return NULL;
+  }
+  result->data = data->data;
+  result->datalen = data->datalen;
+  result->pos = 0;
+  return result;
+}
+
+size_t email_info_attachment_read_memory (void* handle, void* buf, size_t len)
+{
+  struct email_info_attachment_memory_handle_struct* h = (struct email_info_attachment_memory_handle_struct*)handle;
+  size_t n = (h->pos + len <= h->datalen ? len : h->datalen - h->pos);
+  memcpy(buf, h->data + h->pos, n);
+  h->pos += n;
+  return n;
+}
+
+void email_info_attachment_close_memory (void* handle)
+{
+  if (handle)
+    free(handle);
+}
+
+void email_info_attachment_filedata_free_memory (void* filedata)
+{
+  struct email_info_attachment_memory_filedata_struct* data = ((struct email_info_attachment_memory_filedata_struct*)filedata);
+  if (data) {
+    if (data->mustfree)
+      free(data->data);
+    free(data);
+  }
+}
+
+struct email_info_attachment_list_struct* email_info_attachment_list_add_memory (struct email_info_attachment_list_struct** list, const char* filename, const char* mimetype, char* data, size_t datalen, int mustfree)
+{
+  struct email_info_attachment_memory_filedata_struct* filedata;
+  if ((filedata = (struct email_info_attachment_memory_filedata_struct*)malloc(sizeof(struct email_info_attachment_memory_filedata_struct))) == NULL) {
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return NULL;
+  }
+  filedata->data = data;
+  filedata->datalen = datalen;
+  filedata->mustfree = mustfree;
+  return email_info_attachment_list_add(list, filename, mimetype, filedata, email_info_attachment_open_memory, email_info_attachment_read_memory, email_info_attachment_close_memory, email_info_attachment_filedata_free_memory);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_get_version ()
+{
+  return VERSION_STRINGIZE(LIBQUICKMAIL_VERSION_MAJOR, LIBQUICKMAIL_VERSION_MINOR, LIBQUICKMAIL_VERSION_MICRO)
+#if defined(NOCURL)
+    "-light"
+#endif
+  ;
+}
+
+DLL_EXPORT_LIBQUICKMAIL int quickmail_initialize ()
+{
+#if defined(NOCURL) && defined(_WIN32)
+  static WSADATA wsaData;
+  int wsaerr = WSAStartup(MAKEWORD(1, 0), &wsaData);
+  if (wsaerr)
+    return -1;
+  atexit((void(*)())WSACleanup);
+#endif
+  return 0;
+}
+
+DLL_EXPORT_LIBQUICKMAIL quickmail quickmail_create (const char* from, const char* subject)
+{
+  int i;
+  struct email_info_struct* mailobj;
+  if ((mailobj = (struct email_info_struct*)malloc(sizeof(struct email_info_struct))) == NULL) {
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return NULL;
+  }
+  mailobj->current = 0;
+  mailobj->timestamp = time(NULL);
+  mailobj->from = (from ? strdup(from) : NULL);
+  mailobj->to = NULL;
+  mailobj->cc = NULL;
+  mailobj->bcc = NULL;
+  mailobj->subject = (subject ? strdup(subject) : NULL);
+  mailobj->header = NULL;
+  mailobj->bodylist = NULL;
+  mailobj->attachmentlist = NULL;
+  mailobj->buf = NULL;
+  mailobj->buflen = 0;
+  mailobj->mime_boundary_body = NULL;
+  mailobj->mime_boundary_part = NULL;
+  mailobj->current_attachment = NULL;
+  mailobj->debuglog = NULL;
+  for (i = 0; i < 26; i++) {
+    mailobj->dtable[i] = (char)('A' + i);
+    mailobj->dtable[26 + i] = (char)('a' + i);
+  }
+  for (i = 0; i < 10; i++) {
+    mailobj->dtable[52 + i] = (char)('0' + i);
+  }
+  mailobj->dtable[62] = '+';
+  mailobj->dtable[63] = '/';
+  srand(time(NULL));
+  return mailobj;
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_destroy (quickmail mailobj)
+{
+  free(mailobj->from);
+  email_info_string_list_free(&mailobj->to);
+  email_info_string_list_free(&mailobj->cc);
+  email_info_string_list_free(&mailobj->bcc);
+  free(mailobj->subject);
+  free(mailobj->header);
+  email_info_attachment_list_free(&mailobj->bodylist);
+  email_info_attachment_list_free(&mailobj->attachmentlist);
+  free(mailobj->buf);
+  free(mailobj->mime_boundary_body);
+  free(mailobj->mime_boundary_part);
+  free(mailobj);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_from (quickmail mailobj, const char* from)
+{
+  free(mailobj->from);
+  mailobj->from = strdup(from);
+}
+
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_get_from (quickmail mailobj)
+{
+  return mailobj->from;
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_to (quickmail mailobj, const char* email)
+{
+  email_info_string_list_add(&mailobj->to, email);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_cc (quickmail mailobj, const char* email)
+{
+  email_info_string_list_add(&mailobj->cc, email);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_bcc (quickmail mailobj, const char* email)
+{
+  email_info_string_list_add(&mailobj->bcc, email);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_subject (quickmail mailobj, const char* subject)
+{
+  free(mailobj->subject);
+  mailobj->subject = (subject ? strdup(subject) : NULL);
+}
+
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_get_subject (quickmail mailobj)
+{
+  return mailobj->subject;
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_header (quickmail mailobj, const char* headerline)
+{
+  str_append(&mailobj->header, headerline);
+  str_append(&mailobj->header, NEWLINE);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_body (quickmail mailobj, const char* body)
+{
+  email_info_attachment_list_free(&mailobj->bodylist);
+  if (body)
+    email_info_attachment_list_add_memory(&mailobj->bodylist, default_mime_type, default_mime_type, strdup(body), strlen(body), 1);
+}
+
+DLL_EXPORT_LIBQUICKMAIL char* quickmail_get_body (quickmail mailobj)
+{
+  size_t n;
+  char* p;
+  char* result = NULL;
+  size_t resultlen = 0;
+  if (mailobj->bodylist && (mailobj->bodylist->handle = mailobj->bodylist->email_info_attachment_open(mailobj->bodylist->filedata)) != NULL) {
+    do {
+      if ((p = (char*)realloc(result, resultlen + BODY_BUFFER_SIZE)) == NULL) {
+        free(result);
+        DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+        break;
+      }
+      result = p;
+      if ((n = mailobj->bodylist->email_info_attachment_read(mailobj->bodylist->handle, result + resultlen, BODY_BUFFER_SIZE)) > 0)
+        resultlen += n;
+    } while (n > 0);
+    if (mailobj->bodylist->email_info_attachment_close)
+      mailobj->bodylist->email_info_attachment_close(mailobj->bodylist->handle);
+    //else
+    //  free(mailobj->bodylist->handle);
+    mailobj->bodylist->handle = NULL;
+  }
+  return result;
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_body_file (quickmail mailobj, const char* mimetype, const char* path)
+{
+  email_info_attachment_list_add(&mailobj->bodylist, (mimetype ? mimetype : default_mime_type), (mimetype ? mimetype : default_mime_type), (void*)strdup(path), email_info_attachment_open_file, email_info_attachment_read_file, email_info_attachment_close_file, NULL);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_body_memory (quickmail mailobj, const char* mimetype, char* data, size_t datalen, int mustfree)
+{
+  email_info_attachment_list_add_memory(&mailobj->bodylist, (mimetype ? mimetype : default_mime_type), (mimetype ? mimetype : default_mime_type), data, datalen, mustfree);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_body_custom (quickmail mailobj, const char* mimetype, char* data, quickmail_attachment_open_fn attachment_data_open, quickmail_attachment_read_fn attachment_data_read, quickmail_attachment_close_fn attachment_data_close, quickmail_attachment_free_filedata_fn attachment_data_filedata_free)
+{
+  email_info_attachment_list_add(&mailobj->bodylist, (mimetype ? mimetype : default_mime_type), (mimetype ? mimetype : default_mime_type), data, (attachment_data_open ? attachment_data_open : email_info_attachment_open_dummy), (attachment_data_read ? attachment_data_read : email_info_attachment_read_dummy), attachment_data_close, attachment_data_filedata_free);
+}
+
+DLL_EXPORT_LIBQUICKMAIL int quickmail_remove_body (quickmail mailobj, const char* mimetype)
+{
+  return email_info_attachment_list_delete(&mailobj->bodylist, mimetype);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_list_bodies (quickmail mailobj, quickmail_list_attachment_callback_fn callback, void* callbackdata)
+{
+  struct email_info_attachment_list_struct* p = mailobj->bodylist;
+  while (p) {
+    callback(mailobj, p->filename, p->mimetype, p->email_info_attachment_open, p->email_info_attachment_read, p->email_info_attachment_close, callbackdata);
+    p = p->next;
+  }
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_attachment_file (quickmail mailobj, const char* path, const char* mimetype)
+{
+  email_info_attachment_list_add_file(&mailobj->attachmentlist, path, mimetype);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_attachment_memory (quickmail mailobj, const char* filename, const char* mimetype, char* data, size_t datalen, int mustfree)
+{
+  email_info_attachment_list_add_memory(&mailobj->attachmentlist, filename, mimetype, data, datalen, mustfree);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_attachment_custom (quickmail mailobj, const char* filename, const char* mimetype, char* data, quickmail_attachment_open_fn attachment_data_open, quickmail_attachment_read_fn attachment_data_read, quickmail_attachment_close_fn attachment_data_close, quickmail_attachment_free_filedata_fn attachment_data_filedata_free)
+{
+  email_info_attachment_list_add(&mailobj->attachmentlist, filename, mimetype, data, (attachment_data_open ? attachment_data_open : email_info_attachment_open_dummy), (attachment_data_read ? attachment_data_read : email_info_attachment_read_dummy), attachment_data_close, attachment_data_filedata_free);
+}
+
+DLL_EXPORT_LIBQUICKMAIL int quickmail_remove_attachment (quickmail mailobj, const char* filename)
+{
+  return email_info_attachment_list_delete(&mailobj->attachmentlist, filename);
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_list_attachments (quickmail mailobj, quickmail_list_attachment_callback_fn callback, void* callbackdata)
+{
+  struct email_info_attachment_list_struct* p = mailobj->attachmentlist;
+  while (p) {
+    callback(mailobj, p->filename, p->mimetype, p->email_info_attachment_open, p->email_info_attachment_read, p->email_info_attachment_close, callbackdata);
+    p = p->next;
+  }
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_debug_log (quickmail mailobj, FILE* filehandle)
+{
+  mailobj->debuglog = filehandle;
+}
+
+DLL_EXPORT_LIBQUICKMAIL void quickmail_fsave (quickmail mailobj, FILE* filehandle)
+{
+  int i;
+  size_t n;
+  char buf[80];
+  while ((n = quickmail_get_data(buf, sizeof(buf), 1, mailobj)) > 0) {
+    for (i = 0; i < n; i++)
+      fprintf(filehandle, "%c", buf[i]);
+  }
+}
+
+DLL_EXPORT_LIBQUICKMAIL size_t quickmail_get_data (void* ptr, size_t size, size_t nmemb, void* userp)
+{
+  struct email_info_struct* mailobj = (struct email_info_struct*)userp;
+
+  //abort if no data is requested
+  if (size * nmemb == 0)
+    return 0;
+
+  //initialize on first run
+  if (mailobj->current == MAILPART_INITIALIZE) {
+    free(mailobj->buf);
+    mailobj->buf = NULL;
+    mailobj->buflen = 0;
+    free(mailobj->mime_boundary_body);
+    mailobj->mime_boundary_body = NULL;
+    free(mailobj->mime_boundary_part);
+    mailobj->mime_boundary_part = NULL;
+    mailobj->current_attachment = mailobj->bodylist;
+    mailobj->current++;
+  }
+
+  //process current part of mail if no partial data is pending
+  while (mailobj->buflen == 0) {
+    if (mailobj->buflen == 0 && mailobj->current == MAILPART_HEADER) {
+      char* s;
+      //generate header part
+      char** p = &mailobj->buf;
+      mailobj->buf = NULL;
+      str_append(p, "User-Agent: libquickmail v" LIBQUICKMAIL_VERSION NEWLINE);
+      if (mailobj->timestamp != 0) {
+        char timestamptext[32];
+        if (strftime(timestamptext, sizeof(timestamptext), "%a, %d %b %Y %H:%M:%S %z", localtime(&mailobj->timestamp))) {
+          str_append(p, "Date: ");
+          str_append(p, timestamptext);
+          str_append(p, NEWLINE);
+        }
+#ifdef _WIN32
+        //fallback method for Windows when %z (time zone offset) fails
+        else if (strftime(timestamptext, sizeof(timestamptext), "%a, %d %b %Y %H:%M:%S", localtime(&mailobj->timestamp))) {
+          TIME_ZONE_INFORMATION tzinfo;
+          if (GetTimeZoneInformation(&tzinfo) != TIME_ZONE_ID_INVALID)
+            sprintf(timestamptext + strlen(timestamptext), " %c%02i%02i", (tzinfo.Bias > 0 ? '-' : '+'), (int)-tzinfo.Bias / 60, (int)-tzinfo.Bias % 60);
+          str_append(p, "Date: ");
+          str_append(p, timestamptext);
+          str_append(p, NEWLINE);
+        }
+#endif
+      }
+      if (mailobj->from && *mailobj->from) {
+        str_append(p, "From: <");
+        str_append(p, mailobj->from);
+        str_append(p, ">" NEWLINE);
+      }
+      if ((s = email_info_string_list_concatenate(mailobj->to)) != NULL) {
+        str_append(p, "To: ");
+        str_append(p, s);
+        str_append(p, NEWLINE);
+        free(s);
+      }
+      if ((s = email_info_string_list_concatenate(mailobj->cc)) != NULL) {
+        str_append(p, "Cc: ");
+        str_append(p, s);
+        str_append(p, NEWLINE);
+        free(s);
+      }
+      if (mailobj->subject) {
+        str_append(p, "Subject: ");
+        str_append(p, mailobj->subject);
+        str_append(p, NEWLINE);
+      }
+      if (mailobj->header) {
+        str_append(p, mailobj->header);
+      }
+      if (mailobj->attachmentlist) {
+        str_append(p, "MIME-Version: 1.0" NEWLINE);
+      }
+      if (mailobj->attachmentlist) {
+        mailobj->mime_boundary_part = randomize_zeros(strdup("=PART=SEPARATOR=_0000_0000_0000_0000_0000_0000_="));
+        str_append(p, "Content-Type: multipart/mixed; boundary=\"");
+        str_append(p, mailobj->mime_boundary_part);
+        str_append(p, "\"" NEWLINE NEWLINE "This is a multipart message in MIME format." NEWLINE NEWLINE "--");
+        str_append(p, mailobj->mime_boundary_part);
+        str_append(p, NEWLINE);
+      }
+      if (mailobj->bodylist && mailobj->bodylist->next) {
+        mailobj->mime_boundary_body = randomize_zeros(strdup("=BODY=SEPARATOR=_0000_0000_0000_0000_0000_0000_="));
+        str_append(p, "Content-Type: multipart/alternative; boundary=\"");
+        str_append(p, mailobj->mime_boundary_body);
+        str_append(p, NEWLINE);
+      }
+      mailobj->buflen = strlen(mailobj->buf);
+      mailobj->current++;
+    }
+    if (mailobj->buflen == 0 && mailobj->current == MAILPART_BODY) {
+      if (mailobj->current_attachment) {
+        if (!mailobj->current_attachment->handle) {
+          //open file with body data
+          while (mailobj->current_attachment) {
+            if ((mailobj->current_attachment->handle = mailobj->current_attachment->email_info_attachment_open(mailobj->current_attachment->filedata)) != NULL) {
+              break;
+            }
+            mailobj->current_attachment = mailobj->current_attachment->next;
+          }
+          if (!mailobj->current_attachment) {
+            mailobj->current_attachment = mailobj->attachmentlist;
+            mailobj->current++;
+          }
+          //generate attachment header
+          if (mailobj->current_attachment && mailobj->current_attachment->handle) {
+            mailobj->buf = NULL;
+            if (mailobj->mime_boundary_body) {
+              mailobj->buf = str_append(&mailobj->buf, NEWLINE "--");
+              mailobj->buf = str_append(&mailobj->buf, mailobj->mime_boundary_body);
+              mailobj->buf = str_append(&mailobj->buf, NEWLINE);
+            }
+            mailobj->buf = str_append(&mailobj->buf, "Content-Type: ");
+            mailobj->buf = str_append(&mailobj->buf, (mailobj->bodylist && mailobj->current_attachment->filename ? mailobj->current_attachment->filename : default_mime_type));
+            mailobj->buf = str_append(&mailobj->buf, NEWLINE "Content-Transfer-Encoding: 8bit" NEWLINE "Content-Disposition: inline" NEWLINE NEWLINE);
+            mailobj->buflen = strlen(mailobj->buf);
+          }
+        }
+        if (mailobj->buflen == 0 && mailobj->current_attachment && mailobj->current_attachment->handle) {
+          //read body data
+          if ((mailobj->buf = malloc(BODY_BUFFER_SIZE)) == NULL) {
+            DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+          }
+          if (mailobj->buf == NULL || (mailobj->buflen = mailobj->current_attachment->email_info_attachment_read(mailobj->current_attachment->handle, mailobj->buf, BODY_BUFFER_SIZE)) <= 0) {
+            //end of file
+            free(mailobj->buf);
+            mailobj->buflen = 0;
+            if (mailobj->current_attachment->email_info_attachment_close)
+              mailobj->current_attachment->email_info_attachment_close(mailobj->current_attachment->handle);
+            //else
+            //  free(mailobj->current_attachment->handle);
+            mailobj->current_attachment->handle = NULL;
+            mailobj->current_attachment = mailobj->current_attachment->next;
+          }
+        }
+      } else {
+        mailobj->current_attachment = mailobj->attachmentlist;
+        mailobj->current++;
+      }
+    }
+    if (mailobj->buflen == 0 && mailobj->current == MAILPART_BODY_DONE) {
+      mailobj->buf = NULL;
+      if (mailobj->mime_boundary_body) {
+        mailobj->buf = str_append(&mailobj->buf, NEWLINE "--");
+        mailobj->buf = str_append(&mailobj->buf, mailobj->mime_boundary_body);
+        mailobj->buf = str_append(&mailobj->buf, "--" NEWLINE);
+        mailobj->buflen = strlen(mailobj->buf);
+        free(mailobj->mime_boundary_body);
+        mailobj->mime_boundary_body = NULL;
+      }
+      mailobj->current++;
+    }
+    if (mailobj->buflen == 0 && mailobj->current == MAILPART_ATTACHMENT) {
+      if (mailobj->current_attachment) {
+        if (!mailobj->current_attachment->handle) {
+          //open file to attach
+          while (mailobj->current_attachment) {
+            if ((mailobj->current_attachment->handle = mailobj->current_attachment->email_info_attachment_open(mailobj->current_attachment->filedata)) != NULL) {
+              break;
+            }
+            mailobj->current_attachment = mailobj->current_attachment->next;
+          }
+          //generate attachment header
+          if (mailobj->current_attachment && mailobj->current_attachment->handle) {
+            mailobj->buf = NULL;
+            if (mailobj->mime_boundary_part) {
+              mailobj->buf = str_append(&mailobj->buf, NEWLINE "--");
+              mailobj->buf = str_append(&mailobj->buf, mailobj->mime_boundary_part);
+              mailobj->buf = str_append(&mailobj->buf, NEWLINE);
+            }
+            mailobj->buf = str_append(&mailobj->buf, "Content-Type: ");
+            mailobj->buf = str_append(&mailobj->buf, (mailobj->current_attachment->mimetype ? mailobj->current_attachment->mimetype : "application/octet-stream"));
+            mailobj->buf = str_append(&mailobj->buf, "; Name=\"");
+            mailobj->buf = str_append(&mailobj->buf, mailobj->current_attachment->filename);
+            mailobj->buf = str_append(&mailobj->buf, "\"" NEWLINE "Content-Transfer-Encoding: base64" NEWLINE NEWLINE);
+            mailobj->buflen = strlen(mailobj->buf);
+          }
+        } else {
+          //generate next line of attachment data
+          size_t n = 0;
+          int mimelinepos = 0;
+          unsigned char igroup[3] = {0, 0, 0};
+          unsigned char ogroup[4];
+          mailobj->buflen = 0;
+          if ((mailobj->buf = (char*)malloc(MIME_LINE_WIDTH + NEWLINELENGTH + 1)) == NULL) {
+            DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+            n = 0;
+          } else {
+            while (mimelinepos < MIME_LINE_WIDTH && (n = mailobj->current_attachment->email_info_attachment_read(mailobj->current_attachment->handle, igroup, 3)) > 0) {
+              //code data
+              ogroup[0] = mailobj->dtable[igroup[0] >> 2];
+              ogroup[1] = mailobj->dtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)];
+              ogroup[2] = mailobj->dtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)];
+              ogroup[3] = mailobj->dtable[igroup[2] & 0x3F];
+              //padd with "=" characters if less than 3 characters were read
+              if (n < 3) {
+                ogroup[3] = '=';
+                if (n < 2)
+                  ogroup[2] = '=';
+              }
+              memcpy(mailobj->buf + mimelinepos, ogroup, 4);
+              mailobj->buflen += 4;
+              mimelinepos += 4;
+            }
+            if (mimelinepos > 0) {
+              memcpy(mailobj->buf + mimelinepos, NEWLINE, NEWLINELENGTH);
+              mailobj->buflen += NEWLINELENGTH;
+            }
+          }
+          if (n <= 0) {
+            //end of file
+            if (mailobj->current_attachment->email_info_attachment_close)
+              mailobj->current_attachment->email_info_attachment_close(mailobj->current_attachment->handle);
+            else
+              free(mailobj->current_attachment->handle);
+            mailobj->current_attachment->handle = NULL;
+            mailobj->current_attachment = mailobj->current_attachment->next;
+          }
+        }
+      } else {
+        mailobj->current++;
+      }
+    }
+    if (mailobj->buflen == 0 && mailobj->current == MAILPART_END) {
+      mailobj->buf = NULL;
+      mailobj->buflen = 0;
+      if (mailobj->mime_boundary_part) {
+        mailobj->buf = str_append(&mailobj->buf, NEWLINE "--");
+        mailobj->buf = str_append(&mailobj->buf, mailobj->mime_boundary_part);
+        mailobj->buf = str_append(&mailobj->buf, "--" NEWLINE);
+        mailobj->buflen = strlen(mailobj->buf);
+        free(mailobj->mime_boundary_part);
+        mailobj->mime_boundary_part = NULL;
+      }
+      //mailobj->buf = str_append(&mailobj->buf, NEWLINE "." NEWLINE);
+      //mailobj->buflen = strlen(mailobj->buf);
+      mailobj->current++;
+    }
+    if (mailobj->buflen == 0 && mailobj->current == MAILPART_DONE) {
+      break;
+    }
+  }
+
+  //flush pending data if any
+  if (mailobj->buflen > 0) {
+    int len = (mailobj->buflen > size * nmemb ? size * nmemb : mailobj->buflen);
+    memcpy(ptr, mailobj->buf, len);
+    if (len < mailobj->buflen) {
+      mailobj->buf = memmove(mailobj->buf, mailobj->buf + len, mailobj->buflen - len);
+      mailobj->buflen -= len;
+    } else {
+      free(mailobj->buf);
+      mailobj->buf = NULL;
+      mailobj->buflen = 0;
+    }
+    return len;
+  }
+
+  //if (mailobj->current != MAILPART_DONE)
+  //  ;//this should never be reached
+  mailobj->current = 0;
+  return 0;
+}
+
+#ifndef NOCURL
+char* add_angle_brackets (const char* data)
+{
+  size_t datalen = strlen(data);
+  char* result;
+  if ((result = (char*)malloc(datalen + 3)) == NULL) {
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return NULL;
+  }
+  result[0] = '<';
+  memcpy(result + 1, data, datalen);
+  result[datalen + 1] = '>';
+  result[datalen + 2] = 0;
+  return result;
+}
+#endif
+
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_send (quickmail mailobj, const char* smtpserver, unsigned int smtpport, const char* username, const char* password)
+{
+#ifndef NOCURL
+  //libcurl based sending
+  CURL *curl;
+  CURLcode result = CURLE_FAILED_INIT;
+  //curl_global_init(CURL_GLOBAL_ALL);
+  if ((curl = curl_easy_init()) != NULL) {
+    struct curl_slist *recipients = NULL;
+    struct email_info_email_list_struct* listentry;
+    //set destination URL
+    char* addr;
+    size_t len = strlen(smtpserver) + 14;
+    if ((addr = (char*)malloc(len)) == NULL) {
+      DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+      return ERRMSG_MEMORY_ALLOCATION_ERROR;
+    }
+    snprintf(addr, len, "smtp://%s:%u", smtpserver, smtpport);
+    curl_easy_setopt(curl, CURLOPT_URL, addr);
+    free(addr);
+    //try Transport Layer Security (TLS), but continue anyway if it fails
+    curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY);
+    //don't fail if the TLS/SSL a certificate could not be verified
+    //alternative: add the issuer certificate (or the host certificate if
+    //the certificate is self-signed) to the set of certificates that are
+    //known to libcurl using CURLOPT_CAINFO and/or CURLOPT_CAPATH
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
+    //set authentication credentials if provided
+    if (username && *username)
+      curl_easy_setopt(curl, CURLOPT_USERNAME, username);
+    if (password)
+      curl_easy_setopt(curl, CURLOPT_PASSWORD, password);
+    //set from value for envelope reverse-path
+    if (mailobj->from && *mailobj->from) {
+      addr = add_angle_brackets(mailobj->from);
+      curl_easy_setopt(curl, CURLOPT_MAIL_FROM, addr);
+      free(addr);
+    }
+    //set recipients
+    listentry = mailobj->to;
+    while (listentry) {
+      if (listentry->data && *listentry->data) {
+        addr = add_angle_brackets(listentry->data);
+        recipients = curl_slist_append(recipients, addr);
+        free(addr);
+      }
+      listentry = listentry->next;
+    }
+    listentry = mailobj->cc;
+    while (listentry) {
+      if (listentry->data && *listentry->data) {
+        addr = add_angle_brackets(listentry->data);
+        recipients = curl_slist_append(recipients, addr);
+        free(addr);
+      }
+      listentry = listentry->next;
+    }
+    listentry = mailobj->bcc;
+    while (listentry) {
+      if (listentry->data && *listentry->data) {
+        addr = add_angle_brackets(listentry->data);
+        recipients = curl_slist_append(recipients, addr);
+        free(addr);
+      }
+      listentry = listentry->next;
+    }
+    curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
+    //set callback function for getting message body
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, quickmail_get_data);
+    curl_easy_setopt(curl, CURLOPT_READDATA, mailobj);
+    //enable debugging if requested
+    if (mailobj->debuglog) {
+      curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+      curl_easy_setopt(curl, CURLOPT_STDERR, mailobj->debuglog);
+    }
+    //send the message
+    result = curl_easy_perform(curl);
+    //free the list of recipients and clean up
+    curl_slist_free_all(recipients);
+    curl_easy_cleanup(curl);
+  }
+  return (result == CURLE_OK ? NULL : curl_easy_strerror(result));
+#else
+  //minimal implementation without libcurl
+  SOCKET sock;
+  char* errmsg = NULL;
+  struct email_info_email_list_struct* listentry;
+  char local_hostname[64];
+  int statuscode;
+  //determine local host name
+  if (gethostname(local_hostname, sizeof(local_hostname)) != 0)
+		strcpy(local_hostname, "localhost");
+  //connect
+  if ((sock = socket_open(smtpserver, smtpport, &errmsg)) != INVALID_SOCKET) {
+    //talk with SMTP server
+    if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, NULL)) >= 400) {
+      errmsg = "SMTP server returned an error on connection";
+    } else {
+      size_t n;
+      char buf[WRITE_BUFFER_CHUNK_SIZE];
+      do {
+        if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "EHLO %s", local_hostname)) >= 400) {
+          if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "HELO %s", local_hostname)) >= 400) {
+            errmsg = "SMTP EHLO/HELO returned error";
+            break;
+          }
+        }
+        //authenticate if needed
+        if (username || password) {
+          int len;
+          int inpos = 0;
+          int outpos = 0;
+          size_t usernamelen = (username ? strlen(username) : 0);
+          size_t passwordlen = (password ? strlen(password) : 0);
+          char* auth;
+          char* base64auth;
+          if ((auth = (char*)malloc(usernamelen + passwordlen + 4)) == NULL) {
+            DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+            return ERRMSG_MEMORY_ALLOCATION_ERROR;
+          }
+          if ((base64auth = (char*)malloc(((usernamelen + passwordlen + 2) + 2) / 3 * 4 + 1)) == NULL) {
+            DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+            return ERRMSG_MEMORY_ALLOCATION_ERROR;
+          }
+          //leave the authorization identity empty to indicate it's the same the as authentication identity
+          auth[0] = 0;
+          len = 1;
+          //set the authentication identity
+          memcpy(auth + len, (username ? username : ""), usernamelen + 1);
+          len += usernamelen + 1;
+          //set the password
+          memcpy(auth + len, (password ? password : ""), passwordlen + 1);
+          len += passwordlen;
+          //padd with extra zero so groups of 3 bytes can be read
+          auth[usernamelen + len + 1] = 0;
+          //encode in base64
+          while (inpos < len) {
+            //encode data
+            base64auth[outpos + 0] = mailobj->dtable[auth[inpos + 0] >> 2];
+            base64auth[outpos + 1] = mailobj->dtable[((auth[inpos + 0] & 3) << 4) | (auth[inpos + 1] >> 4)];
+            base64auth[outpos + 2] = mailobj->dtable[((auth[inpos + 1] & 0xF) << 2) | (auth[inpos + 2] >> 6)];
+            base64auth[outpos + 3] = mailobj->dtable[auth[inpos + 2] & 0x3F];
+            //padd with "=" characters if less than 3 characters were read
+            if (inpos + 1 >= len) {
+              base64auth[outpos + 3] = '=';
+              if (inpos + 2 >= len)
+                base64auth[outpos + 2] = '=';
+            }
+            //advance to next position
+            inpos += 3;
+            outpos += 4;
+          }
+          base64auth[outpos] = 0;
+          //send originator e-mail address
+          if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "AUTH PLAIN %s", base64auth)) >= 400) {
+            errmsg = "SMTP authentication failed";
+            break;
+          }
+        }
+        //send originator e-mail address
+        if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "MAIL FROM:<%s>", mailobj->from)) >= 400) {
+          errmsg = "SMTP server did not accept sender";
+          break;
+        }
+        //send recipient e-mail addresses
+        listentry = mailobj->to;
+        while (!errmsg && listentry) {
+          if (listentry->data && *listentry->data) {
+            if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "RCPT TO:<%s>", listentry->data)) >= 400)
+              errmsg = "SMTP server did not accept e-mail address (To)";
+          }
+          listentry = listentry->next;
+        }
+        listentry = mailobj->cc;
+        while (!errmsg && listentry) {
+          if (listentry->data && *listentry->data) {
+            if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "RCPT TO:<%s>", listentry->data)) >= 400)
+              errmsg = "SMTP server did not accept e-mail address (CC)";
+          }
+          listentry = listentry->next;
+        }
+        listentry = mailobj->bcc;
+        while (!errmsg && listentry) {
+          if (listentry->data && *listentry->data) {
+            if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "RCPT TO:<%s>", listentry->data)) >= 400)
+              errmsg = "SMTP server did not accept e-mail address (BCC)";
+          }
+          listentry = listentry->next;
+        }
+        if (errmsg)
+          break;
+        //prepare to send mail body
+        if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "DATA")) >= 400) {
+          errmsg = "SMTP DATA returned error";
+          break;
+        }
+        //send mail body data
+        while ((n = quickmail_get_data(buf, sizeof(buf), 1, mailobj)) > 0) {
+          socket_send(sock, buf, n);
+        }
+        //send end of data
+        if ((statuscode = socket_smtp_command(sock, mailobj->debuglog, "\r\n.")) >= 400) {
+          errmsg = "SMTP error after sending message data";
+          break;
+        }
+      } while (0);
+      //log out
+      socket_smtp_command(sock, mailobj->debuglog, "QUIT");
+    }
+  }
+  //close socket
+  socket_close(sock);
+  return errmsg;
+#endif
+}
Index: /AE/RequestHelp/src/quickmail/quickmail.h
===================================================================
--- /AE/RequestHelp/src/quickmail/quickmail.h	(revision 1005)
+++ /AE/RequestHelp/src/quickmail/quickmail.h	(revision 1005)
@@ -0,0 +1,302 @@
+/*! \file      quickmail.h
+ *  \brief     header file for libquickmail
+ *  \author    Brecht Sanders
+ *  \date      2012-2013
+ *  \copyright GPL
+ */
+/*
+    This file is part of libquickmail.
+
+    libquickmail is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    libquickmail is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with libquickmail.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __INCLUDED_QUICKMAIL_H
+#define __INCLUDED_QUICKMAIL_H
+
+#include <stdio.h>
+
+/*! \brief define for exporting/importing functions in/from shared library */
+#ifdef _WIN32
+#if defined(BUILD_QUICKMAIL_DLL)
+#define DLL_EXPORT_LIBQUICKMAIL __declspec(dllexport)
+#elif !defined(STATIC) && !defined(BUILD_QUICKMAIL_STATIC)
+#define DLL_EXPORT_LIBQUICKMAIL __declspec(dllimport)
+#else
+#define DLL_EXPORT_LIBQUICKMAIL
+#endif
+#else
+#define DLL_EXPORT_LIBQUICKMAIL
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief quickmail object type */
+typedef struct email_info_struct* quickmail;
+
+
+
+/*! \brief type of pointer to function for opening attachment data
+ * \param  filedata    custom data as passed to quickmail_add_body_custom/quickmail_add_attachment_custom
+ * \return data structure to be used in calls to quickmail_attachment_read_fn and quickmail_attachment_close_fn functions
+ * \sa     quickmail_add_body_custom()
+ * \sa     quickmail_add_attachment_custom()
+ */
+typedef void* (*quickmail_attachment_open_fn)(void* filedata);
+
+/*! \brief type of pointer to function for reading attachment data
+ * \param  handle      data structure obtained via the corresponding quickmail_attachment_open_fn function
+ * \param  buf         buffer for receiving data
+ * \param  len         size in bytes of buffer for receiving data
+ * \return number of bytes read (zero on end of file)
+ * \sa     quickmail_add_body_custom()
+ * \sa     quickmail_add_attachment_custom()
+ */
+typedef size_t (*quickmail_attachment_read_fn)(void* handle, void* buf, size_t len);
+
+/*! \brief type of pointer to function for closing attachment data
+ * \param  handle      data structure obtained via the corresponding quickmail_attachment_open_fn function
+ * \sa     quickmail_add_body_custom()
+ * \sa     quickmail_add_attachment_custom()
+ */
+typedef void (*quickmail_attachment_close_fn)(void* handle);
+
+/*! \brief type of pointer to function for cleaning up custom data in quickmail_destroy
+ * \param  filedata    custom data as passed to quickmail_add_body_custom/quickmail_add_attachment_custom
+ * \sa     quickmail_add_body_custom()
+ * \sa     quickmail_add_attachment_custom()
+ */
+typedef void (*quickmail_attachment_free_filedata_fn)(void* filedata);
+
+/*! \brief type of pointer to function for cleaning up custom data in quickmail_destroy
+ * \param  mailobj                        quickmail object
+ * \param  filename                       attachment filename (same value as mimetype for mail body)
+ * \param  mimetype                       MIME type
+ * \param  attachment_data_open           function for opening attachment data
+ * \param  attachment_data_read           function for reading attachment data
+ * \param  attachment_data_close          function for closing attachment data (optional, free() will be used if NULL)
+ * \param  callbackdata                   custom data passed to quickmail_list_attachments
+ * \sa     quickmail_list_bodies()
+ * \sa     quickmail_list_attachments()
+ */
+typedef void (*quickmail_list_attachment_callback_fn)(quickmail mailobj, const char* filename, const char* mimetype, quickmail_attachment_open_fn email_info_attachment_open, quickmail_attachment_read_fn email_info_attachment_read, quickmail_attachment_close_fn email_info_attachment_close, void* callbackdata);
+
+
+
+/*! \brief get version quickmail library
+ * \return library version
+ */
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_get_version ();
+
+/*! \brief initialize quickmail library
+ * \return zero on success
+ */
+DLL_EXPORT_LIBQUICKMAIL int quickmail_initialize ();
+
+/*! \brief create a new quickmail object
+ * \param  from        sender e-mail address
+ * \param  subject     e-mail subject
+ * \return quickmail object or NULL on error
+ */
+DLL_EXPORT_LIBQUICKMAIL quickmail quickmail_create (const char* from, const char* subject);
+
+/*! \brief clean up a quickmail object
+ * \param  mailobj     quickmail object
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_destroy (quickmail mailobj);
+
+/*! \brief set the sender (from) e-mail address of a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  from        sender e-mail address
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_from (quickmail mailobj, const char* from);
+
+/*! \brief get the sender (from) e-mail address of a quickmail object
+ * \param  mailobj     quickmail object
+ * \return sender e-mail address
+ */
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_get_from (quickmail mailobj);
+
+/*! \brief add a recipient (to) e-mail address to a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  e-mail      recipient e-mail address
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_to (quickmail mailobj, const char* email);
+
+/*! \brief add a carbon copy recipient (cc) e-mail address to a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  e-mail      recipient e-mail address
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_cc (quickmail mailobj, const char* email);
+
+/*! \brief add a blind carbon copy recipient (bcc) e-mail address to a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  e-mail      recipient e-mail address
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_bcc (quickmail mailobj, const char* email);
+
+/*! \brief set the subject of a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  subject     e-mail subject
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_subject (quickmail mailobj, const char* subject);
+
+/*! \brief set the subject of a quickmail object
+ * \param  mailobj     quickmail object
+ * \return e-mail subject
+ */
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_get_subject (quickmail mailobj);
+
+/*! \brief add an e-mail header to a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  headerline  header line to add
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_header (quickmail mailobj, const char* headerline);
+
+/*! \brief set the body of a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  body        e-mail body
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_body (quickmail mailobj, const char* body);
+
+/*! \brief set the body of a quickmail object
+ * any existing bodies will be removed and a single plain text body will be added
+ * \param  mailobj     quickmail object
+ * \return e-mail body or NULL on error (caller must free result)
+ */
+DLL_EXPORT_LIBQUICKMAIL char* quickmail_get_body (quickmail mailobj);
+
+/*! \brief add a body file to a quickmail object (deprecated)
+ * \param  mailobj     quickmail object
+ * \param  mimetype    MIME type (text/plain will be used if set to NULL)
+ * \param  path        path of file with body data
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_body_file (quickmail mailobj, const char* mimetype, const char* path);
+
+/*! \brief add a body from memory to a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  mimetype    MIME type (text/plain will be used if set to NULL)
+ * \param  data        body content
+ * \param  datalen     size of data in bytes
+ * \param  mustfree    non-zero if data must be freed by quickmail_destroy
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_body_memory (quickmail mailobj, const char* mimetype, char* data, size_t datalen, int mustfree);
+
+/*! \brief add a body with custom read functions to a quickmail object
+ * \param  mailobj                        quickmail object
+ * \param  mimetype                       MIME type (text/plain will be used if set to NULL)
+ * \param  data                           custom data passed to attachment_data_open and attachment_data_filedata_free functions
+ * \param  attachment_data_open           function for opening attachment data
+ * \param  attachment_data_read           function for reading attachment data
+ * \param  attachment_data_close          function for closing attachment data (optional, free() will be used if NULL)
+ * \param  attachment_data_filedata_free  function for cleaning up custom data in quickmail_destroy (optional, free() will be used if NULL)
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_body_custom (quickmail mailobj, const char* mimetype, char* data, quickmail_attachment_open_fn attachment_data_open, quickmail_attachment_read_fn attachment_data_read, quickmail_attachment_close_fn attachment_data_close, quickmail_attachment_free_filedata_fn attachment_data_filedata_free);
+
+/*! \brief remove body from quickmail object
+ * \param  mailobj     quickmail object
+ * \param  mimetype    MIME type (text/plain will be used if set to NULL)
+ * \return zero on success
+ */
+DLL_EXPORT_LIBQUICKMAIL int quickmail_remove_body (quickmail mailobj, const char* mimetype);
+
+/*! \brief list bodies by calling a callback function for each body
+ * \param  mailobj                        quickmail object
+ * \param  callback                       function to call for each attachment
+ * \param  callbackdata                   custom data to pass to the callback function
+ * \sa     quickmail_list_attachment_callback_fn
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_list_bodies (quickmail mailobj, quickmail_list_attachment_callback_fn callback, void* callbackdata);
+
+/*! \brief add a file attachment to a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  path        path of file to attach
+ * \param  mimetype    MIME type of file to attach (application/octet-stream will be used if set to NULL)
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_attachment_file (quickmail mailobj, const char* path, const char* mimetype);
+
+/*! \brief add an attachment from memory to a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  filename    name of file to attach (must not include full path)
+ * \param  mimetype    MIME type of file to attach (set to NULL for default binary file)
+ * \param  data        data content
+ * \param  datalen     size of data in bytes
+ * \param  mustfree    non-zero if data must be freed by quickmail_destroy
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_attachment_memory (quickmail mailobj, const char* filename, const char* mimetype, char* data, size_t datalen, int mustfree);
+
+/*! \brief add an attachment with custom read functions to a quickmail object
+ * \param  mailobj                        quickmail object
+ * \param  filename                       name of file to attach (must not include full path)
+ * \param  mimetype                       MIME type of file to attach (set to NULL for default binary file)
+ * \param  data                           custom data passed to attachment_data_open and attachment_data_filedata_free functions
+ * \param  attachment_data_open           function for opening attachment data
+ * \param  attachment_data_read           function for reading attachment data
+ * \param  attachment_data_close          function for closing attachment data (optional, free() will be used if NULL)
+ * \param  attachment_data_filedata_free  function for cleaning up custom data in quickmail_destroy (optional, free() will be used if NULL)
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_add_attachment_custom (quickmail mailobj, const char* filename, const char* mimetype, char* data, quickmail_attachment_open_fn attachment_data_open, quickmail_attachment_read_fn attachment_data_read, quickmail_attachment_close_fn attachment_data_close, quickmail_attachment_free_filedata_fn attachment_data_filedata_free);
+
+/*! \brief remove attachment from quickmail object
+ * \param  mailobj     quickmail object
+ * \param  filename    name of file to attach (must not include full path)
+ * \return zero on success
+ */
+DLL_EXPORT_LIBQUICKMAIL int quickmail_remove_attachment (quickmail mailobj, const char* filename);
+
+/*! \brief list attachments by calling a callback function for each attachment
+ * \param  mailobj                        quickmail object
+ * \param  callback                       function to call for each attachment
+ * \param  callbackdata                   custom data to pass to the callback function
+ * \sa     quickmail_list_attachment_callback_fn
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_list_attachments (quickmail mailobj, quickmail_list_attachment_callback_fn callback, void* callbackdata);
+
+/*! \brief set the debug logging destination of a quickmail object
+ * \param  mailobj     quickmail object
+ * \param  filehandle  file handle of logging destination (or NULL for no logging)
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_set_debug_log (quickmail mailobj, FILE* filehandle);
+
+/*! \brief save the generated e-mail to a file
+ * \param  mailobj     quickmail object
+ * \param  filehandle  file handle to write the e-mail contents to
+ */
+DLL_EXPORT_LIBQUICKMAIL void quickmail_fsave (quickmail mailobj, FILE* filehandle);
+
+/*! \brief read data the next data from the e-mail contents (can be used as CURLOPT_READFUNCTION callback function)
+ * \param  buffer      buffer to copy data to (bust be able to hold size * nmemb bytes)
+ * \param  size        record size
+ * \param  nmemb       number of records to copy to \p buffer
+ * \param  mailobj     quickmail object
+ * \return number of bytes copied to \p buffer or 0 if at end
+ */
+DLL_EXPORT_LIBQUICKMAIL size_t quickmail_get_data (void* buffer, size_t size, size_t nmemb, void* mailobj);
+
+/*! \brief send the e-mail via SMTP
+ * \param  mailobj     quickmail object
+ * \param  smtpserver  IP address or hostname of SMTP server
+ * \param  smtpport    SMTP port number (normally this is 25)
+ * \param  username    username to use for authentication (or NULL if not needed)
+ * \param  password    password to use for authentication (or NULL if not needed)
+ * \return NULL on success or error message on error
+ */
+DLL_EXPORT_LIBQUICKMAIL const char* quickmail_send (quickmail mailobj, const char* smtpserver, unsigned int smtpport, const char* username, const char* password);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__INCLUDED_QUICKMAIL_H
Index: /AE/RequestHelp/src/quickmail/smtpsocket.c
===================================================================
--- /AE/RequestHelp/src/quickmail/smtpsocket.c	(revision 1005)
+++ /AE/RequestHelp/src/quickmail/smtpsocket.c	(revision 1005)
@@ -0,0 +1,235 @@
+/*
+    This file is part of libquickmail.
+
+    libquickmail is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    libquickmail is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with libquickmail.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "smtpsocket.h"
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#if _MSC_VER
+#define va_copy(dst,src) ((dst) = (src))
+#endif
+
+////////////////////////////////////////////////////////////////////////
+
+#define DEBUG_ERROR(errmsg)
+static const char* ERRMSG_MEMORY_ALLOCATION_ERROR = "Memory allocation error";
+
+////////////////////////////////////////////////////////////////////////
+
+SOCKET socket_open (const char* smtpserver, unsigned int smtpport, char** errmsg)
+{
+  struct in_addr ipv4addr;
+  SOCKET sock;
+  struct sockaddr_in remote_sock_addr;
+  static const struct linger linger_option = {-1, 2};   //linger 2 seconds when disconnecting
+  //determine IPv4 address of SMTP server
+  ipv4addr.s_addr = inet_addr(smtpserver);
+  if (ipv4addr.s_addr == INADDR_NONE) {
+    struct hostent* addr;
+    if ((addr = gethostbyname(smtpserver)) != NULL && (addr->h_addrtype == AF_INET && addr->h_length >= 1 && ((struct in_addr*)addr->h_addr)->s_addr != 0))
+      memcpy(&ipv4addr, addr->h_addr, sizeof(ipv4addr));
+  }
+  if (ipv4addr.s_addr == INADDR_NONE) {
+    if (errmsg)
+      *errmsg = "Unable to resolve SMTP server host name";
+    return INVALID_SOCKET;
+  }
+  //create socket
+  sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+  if (sock == INVALID_SOCKET) {
+    if (errmsg)
+      *errmsg = "Error creating socket for SMTP connection";
+    return INVALID_SOCKET;
+  }
+  //connect
+  remote_sock_addr.sin_family = AF_INET;
+  remote_sock_addr.sin_port = htons(smtpport);
+  remote_sock_addr.sin_addr.s_addr = ipv4addr.s_addr;
+  if (connect(sock, (struct sockaddr*)&remote_sock_addr, sizeof(remote_sock_addr)) != 0) {
+    if (errmsg)
+      *errmsg = "Error connecting to SMTP server";
+    socket_close(sock);
+    return INVALID_SOCKET;
+  }
+  //set linger option
+  setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char*)&linger_option, sizeof(linger_option));
+  return sock;
+}
+
+void socket_close (SOCKET sock)
+{
+#ifndef _WIN32
+  shutdown(sock, 2);
+#else
+  closesocket(sock);
+#endif
+}
+
+int socket_send (SOCKET sock, const char* buf, int len)
+{
+  int total_sent = 0;
+  int l = 0;
+  if (sock == 0 || !buf)
+    return 0;
+  if (len < 0)
+    len = strlen(buf);
+  while (len > 0 && (l = send(sock, buf, len, 0)) < len) {
+    if (l == SOCKET_ERROR || l > len)
+      return (total_sent > 0 ? total_sent : -1);
+    total_sent += l;
+    buf += l;
+    len -= l;
+  }
+  return total_sent + l;
+}
+
+int socket_data_waiting (SOCKET sock, int timeoutseconds)
+{
+  fd_set rfds;
+  struct timeval tv;
+  if (sock == 0)
+    return 0;
+  //make a set with only this socket
+  FD_ZERO(&rfds);
+  FD_SET(sock, &rfds);
+  //make a timeval with the supplied timeout
+  tv.tv_sec = timeoutseconds;
+  tv.tv_usec = 0;
+  //check the socket
+  return (select(1, &rfds, NULL, NULL, &tv) > 0);
+}
+
+char* socket_receive_smtp (SOCKET sock)
+{
+  char* buf = NULL;
+  int bufsize = READ_BUFFER_CHUNK_SIZE;
+  int pos = 0;
+  int linestart;
+  int n;
+  if ((buf = (char*)malloc(bufsize)) == NULL) {
+    DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+    return NULL;
+  }
+  do {
+    //insert line break if response is multiple lines
+    if (pos > 0) {
+      buf[pos++] = '\n';
+      if (pos >= bufsize) {
+        char* newbuf;
+        if ((newbuf = (char*)realloc(buf, bufsize + READ_BUFFER_CHUNK_SIZE)) == NULL) {
+          free(buf);
+          DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+          return NULL;
+        }
+        buf = newbuf;
+        bufsize += READ_BUFFER_CHUNK_SIZE;
+      }
+    }
+    //add each character read until it is a line break
+    linestart = pos;
+    while ((n = recv(sock, buf + pos, 1, 0)) == 1) {
+      //detect optional carriage return (CR)
+      if (buf[pos] == '\r')
+        if (recv(sock, buf + pos, 1, 0) < 1)
+          return NULL;
+      //detect line feed (LF)
+      if (buf[pos] == '\n')
+        break;
+      //enlarge buffer if necessary
+      if (++pos >= bufsize) {
+        char* newbuf;
+        if ((newbuf = (char*)realloc(buf, bufsize + READ_BUFFER_CHUNK_SIZE)) == NULL) {
+          free(buf);
+          DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+          return NULL;
+        }
+        buf = newbuf;
+        bufsize += READ_BUFFER_CHUNK_SIZE;
+      }
+    }
+    //exit on error (e.g. if connection is closed)
+    if (n < 1)
+      return NULL;
+  } while (!isdigit(buf[linestart]) || !isdigit(buf[linestart + 1]) || !isdigit(buf[linestart + 2]) || buf[linestart + 3] != ' ');
+  buf[pos] = 0;
+  return buf;
+}
+
+int socket_get_smtp_code (SOCKET sock, char** message)
+{
+  int code;
+  char* buf = socket_receive_smtp(sock);
+  if (!buf || strlen(buf) < 4 || (buf[3] != ' ' && buf[3] != '-')) {
+    free(buf);
+    return 999;
+  }
+  //get code
+  buf[3] = 0;
+  code = atoi(buf);
+  //get error message (if needed)
+  if (message /*&& code >= 400*/)
+    *message = strdup(buf + 4);
+  //clean up and return
+  free(buf);
+  return code;
+}
+
+int socket_smtp_command (SOCKET sock, FILE* debuglog, const char* template, ...)
+{
+  char* message;
+  int statuscode;
+  //send command (if one is supplied)
+  if (template) {
+    va_list ap;
+    va_list aq;
+    char* cmd;
+    int cmdlen;
+    va_start(ap, template);
+    //construct command to send
+    va_copy(aq, ap);
+    cmdlen = vsnprintf(NULL, 0, template, aq);
+    va_end(aq);
+    if ((cmd = (char*)malloc(cmdlen + 3)) == NULL) {
+      DEBUG_ERROR(ERRMSG_MEMORY_ALLOCATION_ERROR)
+      if (debuglog)
+        fprintf(debuglog, ERRMSG_MEMORY_ALLOCATION_ERROR);
+      va_end(ap);
+      return 999;
+    }
+    vsnprintf(cmd, cmdlen + 1, template, ap);
+    //log command to send
+    if (debuglog)
+      fprintf(debuglog, "SMTP> %s\n", cmd);
+    //append CR+LF
+    strcpy(cmd + cmdlen, "\r\n");
+    cmdlen += 2;
+    //send command
+    statuscode = socket_send(sock, cmd, cmdlen);
+		//clean up
+    free(cmd);
+    va_end(ap);
+    if (statuscode < 0)
+      return 999;
+  }
+  //receive result
+  message = NULL;
+  statuscode = socket_get_smtp_code(sock, &message);
+  if (debuglog)
+    fprintf(debuglog, "SMTP< %i %s\n", statuscode, (message ? message : ""));
+  free(message);
+  return statuscode;
+}
Index: /AE/RequestHelp/src/quickmail/smtpsocket.h
===================================================================
--- /AE/RequestHelp/src/quickmail/smtpsocket.h	(revision 1005)
+++ /AE/RequestHelp/src/quickmail/smtpsocket.h	(revision 1005)
@@ -0,0 +1,107 @@
+/*! \file      smtpsocket.h
+ *  \brief     header file for TCP/IP socket and SMTP communication functions
+ *  \author    Brecht Sanders
+ *  \date      2012-2013
+ *  \copyright GPL
+ */
+/*
+    This file is part of libquickmail.
+
+    libquickmail is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    libquickmail is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with libquickmail.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __INCLUDED_SMTPSOCKET_H
+#define __INCLUDED_SMTPSOCKET_H
+
+#ifdef _WIN32
+#include <winsock2.h>
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#ifndef SOCKET
+#define SOCKET int
+#endif
+#ifndef INVALID_SOCKET
+#define INVALID_SOCKET -1
+#endif
+#ifndef SOCKET_ERROR
+#define SOCKET_ERROR -1
+#endif
+#endif
+#include <stdio.h>
+#include <stdarg.h>
+
+#define READ_BUFFER_CHUNK_SIZE 128
+#define WRITE_BUFFER_CHUNK_SIZE 128
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief connect network socket
+ * \param  smtpserver      hostname or IP address of server
+ * \param  smtpport        TCP port to connect to
+ * \param  errmsg          optional pointer to where error message will be stored (must not be freed by caller)
+ * \return open network socket or INVALID_SOCKET on error
+*/
+SOCKET socket_open (const char* smtpserver, unsigned int smtpport, char** errmsg);
+
+/*! \brief disconnect network socket
+ * \param  sock        open network socket
+*/
+void socket_close (SOCKET sock);
+
+/*! \brief send data to a network socket
+ * \param  sock        open network socket
+ * \param  buf         buffer containing data
+ * \param  len         size of buffer in bytes
+ * \return number of bytes sent
+*/
+int socket_send (SOCKET sock, const char* buf, int len);
+
+/*! \brief check if data is waiting to be read from network socket
+ * \param  sock            open network socket
+ * \param  timeoutseconds  number of seconds to wait (0 to return immediately)
+ * \return nonzero if data is waiting
+*/
+int socket_data_waiting (SOCKET sock, int timeoutseconds);
+
+/*! \brief read SMTP response from network socket
+ * \param  sock            open network socket
+ * \return null-terminated string containing received data (must be freed by caller), or NULL
+*/
+char* socket_receive_stmp (SOCKET sock);
+
+/*! \brief read SMTP response from network socket
+ * \param  sock            open network socket
+ * \param  errmsg          optional pointer to where error message will be stored (must be freed by caller)
+ * \return SMTP status code (code >= 400 means error)
+*/
+int socket_get_smtp_code (SOCKET sock, char** errmsg);
+
+/*! \brief send SMTP command and return status code
+ * \param  sock            open network socket
+ * \param  debuglog        file handle to write debugging information to (NULL for no debugging)
+ * \param  template        printf style formatting template
+ * \return SMTP status code (code >= 400 means error)
+*/
+int socket_smtp_command (SOCKET sock, FILE* debuglog, const char* template, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__INCLUDED_SMTPSOCKET_H
