把Golang版github.com/jordan-wright/email发邮件的库做成dll动态库,精简成一个函数SendEmail即可发邮件,各种开发语言都可调用。代码已开源:https://github.com/6550523/EmailDll
C++ 调用发邮件范例:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#define ERR_LEN 1024
#ifdef _WIN64
#define DLL_PATH _T("..\\..\\Release\\email-win-64.dll")
#else
#define DLL_PATH _T("..\\..\\Release\\email-win-32.dll")
#endif
int main()
{
HMODULE module = LoadLibrary(DLL_PATH);
if (module == NULL)
{
DWORD err = GetLastError();
printf("Load email.dll failed %d\n", err);
return -1;
}
//SendEmail
typedef void(*SendEmailFunc)(char *, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*);
SendEmailFunc SendEmail;
SendEmail = (SendEmailFunc)GetProcAddress(module, "SendEmail");