📄 smtp.h
字号:
#ifndef _GNU_SOCK_SMTP_H#define _GNU_SOCK_SMTP_H #include <string.h>#include <stdlib.h>#include <stdio.h>#include <stdarg.h>#ifdef WIN32 #include <winerror.h> #include <wininet.h> #include <winsock.h> #include <stdint.h> #include <ws2tcpip.h> #define close closesocket #define sockstart(name) \ WSADATA name; \ if (WSAStartup(MAKEWORD(1,1) ,&name)){ \ perror("sockstart") ; \ } #define sockend() WSACleanup()#else #include <unistd.h> #include <sys/socket.h> #include <sys/types.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netdb.h> #define sockstart(name) #define sockend()#endif/* Write By: Gan Jian Hui * Date :2006-06-10 **/#define m_strcpy(dest,src) _m_strcpy(&dest,src)/* The MailHeader*/typedef struct { char *mailFrom ; char *mailTo ; char *ccTo ; char *mailHost ; char *userName ; char *passWord ;} MailHeader,*pMailHeader ;#define INIT_MAILHEADER(header) \ header = malloc(sizeof(MailHeader)) ;\ memset(header,0,sizeof(MailHeader)) #define FREE_MAILHEADER(header) \ free(header -> mailFrom); \ free(header -> mailTo); \ free(header -> ccTo); \ free(header -> mailHost) ; \ free(header->userName) ; \ free(header->passWord) ; \ free(header) /* The Mail Information */typedef struct { MailHeader *header ; char *subject; char *contentType; char *mailBody ; char *charSet ;} Mail,*pMail ;#define INIT_MAIL(mail) \ mail = malloc(sizeof(Mail)) ;\ memset(mail,0,sizeof(Mail));\ INIT_MAILHEADER(mail->header) #define FREE_MAIL(mail) \ free(mail -> subject) ; \ free(mail -> contentType) ; \ free(mail -> mailBody) ; \ free(mail -> charSet) ; \ if ( mail->header) { FREE_MAILHEADER(mail-> header);} \ free(mail) /*encoding base64*/ int Base64Enc(char *buf,char *text) ;int Base64Dec(char *buf,char*text,int size) ; int DecodeQuoted(const char* pSrc, unsigned char* pDst, int nSrcLen) ;int EncodeQuoted(const unsigned char* pSrc, char* pDst, int nSrcLen, int nMaxLineLen,int action) ;char* EncodeQuotednew(const unsigned char* pSrc, int nSrcLen, int nMaxLineLen) ; int hostsend(int sock, char *format, ...) ; int hostconnect(const char *hostname, uint16_t port) ;int sendsmtpmail(int sockfd, Mail *mail) ;void die(const char *fmt, ...) ;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -