📄 maillip.h
字号:
/***********************************************************文件名:maillip.h 自定义头文件功能:SMTP数据结构的定义和函数的定义完成日期:2004.7.18***********************************************************/#include <sys/types.h>#include <sys/socket.h>#include <stdio.h>#include <string.h>#include <ctype.h>#include <time.h>#include <sys/time.h>#include <stdlib.h>#include <stdarg.h> //for variable argument lists#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#include <netdb.h>#include <errno.h>#include <malloc.h>/*************************************************************************相关信息的初始化*************************************************************************/
#define VERSION "0.2.2"#define MAX_CONFIG_LINE_SIZE 255#define MAIL_IP_DEBUG 0#define MASS_MAIL 0#define MAIL_TITTLE "hello from S4510"#ifndef _smtpmail_included /*allow multiple inclusions*/#define _smtpmail_included#define SMTP_MAILER_NAME "smtpmail function"#define TESTING 0#define SILENT 1#define TRUE 1#define FALSE 0/* Macro to encoding a char and make it printable. */#define ENC(c) ((c) ? ((c) & 077) + ' ': '`')/* Macro to write too the smtp port. *//*****************************************************************************smtp信息结构体的定义*****************************************************************************/typedef struct SMTP { char *strSmtpServer; //This is the "xxx.xxx.xxx.xxx" string //IP Addrress of the SMTP mail server or //the address of the SMTP Proxy server char *strSubject; //String containing the Subject of the e-mail. char *strMessageBody; //String of the Message Body. May be //multiple lines seperated by crlfs //terminated by a NULL char *strSenderUserId; //string containing the e-mail address of //the sender ex: "padamo@worldnet.att.net" char *strFullSenderUserId; //alternate sender e-mail address in the //following form: //""Pat Adamo" <padamo@worldnet.att.net>" char *strDestUserIds; //String formatted as a list of recipient //e-mail addresses char *strFullDestUserIds; //alternate list of recipient e-mail address //in the following form: char *strRplyPathUserId; //e-mail address to address replies to char *strRrcptUserId; //e-mail address to send return receipt //the sender ex: "padamo@worldnet.att.net" char *strMsgComment; //String Message Comment (optional) char *strMailerName; //Name of function or program sending this char *strattachment; //message. If not supplied, will be //substituted with defn SMTP_MAILER_NAME int sock_fd; //internal storage for socket file descriptor int connect_retry_cnt; //number of tries to connect to server int retry_wait_time; //amount of time to wait before retries } SMTP;#endifstatic char *months [] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };static char *days [] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; SMTP smtp;/****************************************************************************************函数的定义****************************************************************************************/
long date_now (void);
time_t date_to_timer (long date, long time);
int day_of_week (long date);
char * encode_mime_time (long date, long time);
static int getreply (int iSocket, SMTP *smtp);
char * getstrfld (char *strbuf, int fldno, int ofset, char *sep, char *retstr);
void local_to_gmt (long date, long time, long *gmt_date, long *gmt_time);
char * ltrim (char *string);
void mail(unsigned char *dst,unsigned char *src,unsigned char tittle[30], \ unsigned char body[200],unsigned char attachment[200]);
char * replacechrswith (char *strbuf, char *chrstorm, char chartorlcwith);
int search_config_file(char *filename, char *keyword, char *value);
void smtp_clear(SMTP * smtp);
int smtp_connect(SMTP * smtp);
char * smtp_fill_in_addresses(char * source_string);
void smtp_print(SMTP * smtp);
void smtp_send_data(int sock,char * strout);
int smtp_send_mail (SMTP *smtp, int show_progress);
int smtp_send_mail_func (SMTP *smtp,int recipient_index, int show_progress);
char * strcrop (char *string);
long time_now (void);
long timer_to_date (time_t time_secs);
long timer_to_gmdate (time_t time_secs);
long timer_to_gmtime (time_t time_secs);
long timer_to_time (time_t time_secs);
char * trim (char *strin);
char * xstrcat (char *dest, const char *src, ...);
char * xstrcpy (char *dest, const char *src, ...); /***************************************************************************************base64编码的码字及函数***************************************************************************************/static char *ch64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
unsigned char *encode(unsigned char *src,int srclen);
unsigned char *decode(unsigned char *src);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -