亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mailer_class.cpp.svn-base

?? 這是一個很好的參考代碼
?? SVN-BASE
?? 第 1 頁 / 共 3 頁
字號:
#include <fstream>#include <sstream>#include <ctime>#include <cassert>#include "mailer_class.h"#include "base64.h"/* constructors */Mailer::Mailer(const char *TOaddress, const char *FROMaddress, const char *Subject, const std::vector<char> &Message, 	       const char *Nameserver, unsigned short Port, bool MXLookup) : type(LOGIN), subject(Subject), 									     server(getserveraddress(TOaddress)), 									     nameserver(Nameserver), port(htons(Port)),									     lookupMXRecord(MXLookup), auth(false){  /* parse the email address into an address structure */  setsender(FROMaddress); // set from address  addrecipient(TOaddress); // set to address  setmessage(Message); // set message  initNetworking(); // initialize connection}Mailer::Mailer(const char* TOaddress, const char* FROMaddress, const char* Subject, const char* Message, 	       const char* Nameserver, unsigned short Port,  bool MXLookup): type(LOGIN), subject(Subject), 									     server(getserveraddress(TOaddress)),									     nameserver(Nameserver), port(htons(Port)),									     lookupMXRecord(MXLookup), auth(false) {  /* parse the email addresses into an address structure. */  setsender(FROMaddress); // set from address  addrecipient(TOaddress); // set to address  setmessage(Message); // set message  initNetworking(); // initialize connection}Mailer::Mailer(bool MXLookup, unsigned short Port) : type(LOGIN), port(htons(Port)), lookupMXRecord(MXLookup),						     auth(false) {  initNetworking(); // initialize connection}Mailer::~Mailer() { } /* set the mail body */bool Mailer::setmessage(const std::string &newmessage){  /* check if we have an empty message */  if(!newmessage.length()) {    return false; // this is an error  }  message.clear(); // erase the old message  /* check if message is valid */  for(std::string::size_type i=0; i<newmessage.length(); ++i) {    message.push_back(newmessage[i]);  }  /* check if we're RFC compliant */  checkRFCcompat();  return true;}bool Mailer::setmessage(const std::vector<char> &newmessage){  /* check if we have an empty message */  if(!newmessage.size()) {    return false;  }  message = newmessage; // set the message  /* check if we're RFC compliant */  checkRFCcompat();  return true;}/* set a HTML message */bool Mailer::setmessageHTML(const std::string &newmessage){  /* check if we have an empty message */  if(!newmessage.length()) {    return false;  }  messageHTML.clear(); // erase old message  /* is this message valid? */  for(std::string::size_type i=0; i<newmessage.length(); ++i) {    messageHTML.push_back(newmessage[i]);  }  messageHTML = base64encode(messageHTML); // encode message  return true;}bool Mailer::setmessageHTML(const std::vector<char> &newmessage){  /* check if we have an empty message */  if(!newmessage.size()) {    return false;  }  messageHTML = base64encode(newmessage); // encode message  return true;}/* set a message from an HTML file */bool Mailer::setmessageHTMLfile(const std::string &filename){  /* check if we have an empty message */  if(!filename.length()) {    return false;  }  /* open file */  std::ifstream file(filename.c_str(), std::ios::binary | std::ios::in);  /* could we open the file */  if(!file) {    return false;  }  std::vector<char> filedata;  /* read file data */  char c = file.get();  for( ; file.good(); c=file.get()) {    if(file.bad()) {      break;    }    filedata.push_back(c);  }  messageHTML = base64encode(filedata); // encode message  return true;}/* check if all is RFC compliant */void Mailer::checkRFCcompat() {  /* Check the line breaks. */  std::vector<char>::iterator it;  for(it = message.begin(); it != message.end(); ++it) {    /* look for \n add \r before if not there. Pretty lame but still. haven't thought of a better way yet. */    if(*it == '\n') {      if(it == message.begin()) {        it = message.insert(it, '\r');        ++it; // step past newline        continue;      }      if((*(it -1) != '\r') ) {        /* add a return before '\n' */        it = message.insert(it, '\r');        ++it; // step past newline      }    }  }  /* if we get a period on a line by itself   * add another period to stop the server ending the mail prematurely.   * ( suggested by david Irwin )   */  if(message.size() == 1) {    if(*(message.begin()) == '.') {      message.push_back('.');    }  } else if(message.size() == 2) {    if(*(message.begin()) == '.') {      it = message.begin();      it = message.insert(it, '.');    }  } else {    if(*(message.begin()) == '.') {      it = message.begin();      it = message.insert(it, '.');    }    for(it = message.begin()+2; it != message.end(); ++it) {      /* follow the rfc. Add '.' if the first character on a line is '.' */      if(*it == '\n') {        if( ((it + 1) != message.end()) && (*(it +1) == '.') ) {          it = message.insert(it + 1, '.');          ++it; // step past        }      }    }  }  /* don't do anything if we are not longer than a 1000 characters */  if(message.size() < 1000) {    return;  }  /* now we have checked line breaks check line lengths. */  int count(1);  for(it = message.begin(); it < message.end(); ++it, ++count) {    if(*it == '\r') {      count = 0; // reset for a new line.      ++it; // get past newline      continue;    } else if(count >= 998) {      ++it;      if(*it != ' ') { // we are not in a word!!        /* it should never get to message.begin() because we start at least 998 chars into the message!         * Also, assume a word isn't bigger than 997 chars! (seems reasonable)          */	std::vector<char>::iterator pos = it;        for(int j = 0; j < 997; ++j, --pos) {          if(*pos == ' ') {            it = ++pos; // get past the space.            break;          }        }      }      if(it < message.end()) {        it = message.insert(it, '\r');      }      ++it;      if(it < message.end()) {        it = message.insert(it, '\n');      }      count = 0; // reset for a new line.    }  }  count=1; // reset the count  if(messageHTML.size()) {    for(it = messageHTML.begin(); it < messageHTML.end(); ++it, ++count) {      if(*it == '\r') {        count = 0; // reset for a new line.        ++it; // get past newline        continue;      } else if(count >= 998) {        ++it;        if(*it != ' ') { // we are in a word!!          /* it should never get to message.begin() because we           * start at least 998 chars into the message!           * Assume a word isn't bigger than 997 chars! (seems reasonable)           */	  std::vector<char>::iterator pos = it;          for(int j = 0; j < 997; ++j, --pos) {            if(*pos == ' ') {              it = ++pos; // get past the space.              break;            }          }        }        if(it < messageHTML.end()) {          it = messageHTML.insert(it, '\r');        }        ++it;        if(it < messageHTML.end()) {          it = messageHTML.insert(it, '\n');        }        count = 0; // reset for a new line.      }    }  }}/* set the subject line */bool Mailer::setsubject(const std::string& newSubject) {  /* do we have a non-empty subject? */  if(!newSubject.length()) {    return false;  }  subject = newSubject; // set subject  return true;}/* set SMTP server */bool Mailer::setserver(const std::string& nameserver_or_smtpserver) {  /* is a servername given? */  if(!nameserver_or_smtpserver.length()) {    return false;  }  nameserver = nameserver_or_smtpserver;  return true;}/* set FROM address */bool Mailer::setsender(const std::string& newsender) {  /* do we have an empty sender? */  if(!newsender.length()) {    return false;  }  /* parse and set sender address */  Address newaddress(parseaddress(newsender));  fromAddress = newaddress;  return true;}/* set TO address */bool Mailer::addrecipient(const std::string& newrecipient, short recipient_type){  /* SMTP only allows 100 recipients max at a time. rfc821 */  if(recipients.size() >= 100) { // == would be fine, but let's be stupid safe    return false;  }  if(newrecipient.length()) {    /* If there are no recipients yet set the server address for MX queries */    if(!recipients.size()) {      server = getserveraddress(newrecipient);    }    Address newaddress = parseaddress(newrecipient);    if(recipient_type > Bcc || recipient_type < TO) {      recipient_type = Bcc; // default to blind copy on error(hidden is better)    }    recipients.push_back(std::make_pair(newaddress, recipient_type));    return true;  }  return false;}/* remove a recipient from the list */bool Mailer::removerecipient(const std::string& recipient) {  if(recipient.length()) { // there is something to remove    std::vector<std::pair<Address, short> >::iterator it(recipients.begin());    for(; it < recipients.end(); ++it) {      if((*it).first.address == recipient) {        recipients.erase(it);        return true;      }    }    /* fall through as we did not find this recipient */  }  return false;}/* clear all recipient from the list */void Mailer::clearrecipients() {  recipients.clear();}/* clear all attachments from the list */void Mailer::clearattachments() {  attachments.clear();}/* reset the program */void Mailer::reset() {  recipients.clear(); // reset recipient list  attachments.clear(); // reset attachment list  server = ""; // reset SMTP server  message.clear(); // reset message  messageHTML.clear(); // reset HTML message  returnstring = ""; // clear out any errors from previous use}/* convenience funtion */void Mailer::send() {  operator()();}/* this is where we do all the work. */void Mailer::operator()() {  returnstring = ""; // clear out any errors from previous use  if(!recipients.size()) { // we need a recipient    returnstring = "451 Requested action aborted: local error who am I mailing";    return;  }  if(!fromAddress.address.length()) { // we need a sender    returnstring = "451 Requested action aborted: local error who am I";    return;  }  if(!nameserver.length()) { // no SMTP or nameserver given    returnstring = "451 Requested action aborted: local error no SMTP/name server/smtp server";    return;  }  std::vector<SOCKADDR_IN> adds;  /* lookup for a MX record */  if(lookupMXRecord) {    if(!gethostaddresses(adds)) {      /* error!! we are dead. */      returnstring = "451 Requested action aborted: No MX records ascertained";      return;    }  } else { // connect directly to an SMTP server.    SOCKADDR_IN addr(nameserver, port, AF_INET);    hostent* host = 0;    if(addr) {      host = gethostbyaddr(addr.get_sin_addr(), sizeof(addr.ADDR.sin_addr), AF_INET);    } else {      host = gethostbyname(nameserver.c_str());    }    if(!host) {      returnstring = "451 Requested action aborted: local error in processing";      return; // error!!!    }    std::copy(host->h_addr_list[0], host->h_addr_list[0] + host->h_length, addr.	      get_sin_addr());    adds.push_back(addr);  }  /* create the client socket */  SOCKET s;  if(!Socket(s, AF_INET, SOCK_STREAM, 0)) {    returnstring =  "451 Requested action aborted: socket function error";    return;  }  if(!adds.size()) { // oops    returnstring = "451 Requested action aborted: No MX records ascertained";  }  const std::string OK("250");  const std::vector<char> smtpheader(makesmtpmessage());  const int buffsize(1024);  char buff[buffsize] = "";  for(std::vector<SOCKADDR_IN>::const_iterator address = adds.begin(); address <	adds.end(); ++address) {    if(!Connect(s, *address)) { // connect to SMTP server      returnstring = "554 Transaction failed: server connect error.";      continue;    }    /* 220 the server line returned here */    int len1;    if(!Recv(len1, s, buff, buffsize, 0)) {      returnstring = "554 Transaction failed: server connect response error.";      continue;    }    /* get our hostname to pass to the smtp server */    char hn[buffsize] = "";    if(gethostname(hn, buffsize)) {      /* no local hostname!!! make one up */      strcpy(hn, "bitmailer");    }    /* say hello to the server */    std::string commandline(std::string("EHLO ") + hn + std::string("\r\n"));    if(!Send(len1, s, commandline.c_str(), commandline.length(), 0)) {      returnstring = "554 Transaction failed: EHLO send";      continue;    }    /* check for error on EHLO */    if(!Recv(len1, s, buff, buffsize, 0)) {      returnstring = "554 Transaction failed: EHLO receipt";      continue;    }    buff[len1] = '\0';    std::string greeting = returnstring = buff;    if(returnstring.substr(0,3) != OK) {      if(auth) {        /* oops no ESMTP but using authentication no go bail out! */        returnstring = "554 possibly trying to use AUTH without ESMTP server, ERROR!";        continue;      }      /* maybe we only do non extended smtp, send HELO instead. */      commandline[0] = 'H';      commandline[1] = 'E';      if(!Send(len1, s, commandline.c_str(), commandline.length(), 0)) {        returnstring = "554 Transaction failed: HELO send";        continue;      }      if(!Recv(len1, s, buff, buffsize, 0)) {        returnstring = "554 Transaction failed: HELO receipt";        continue;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美电影免费提供在线观看| 在线观看国产91| 午夜精品福利一区二区蜜股av| 成人免费一区二区三区视频| 亚洲欧洲日韩综合一区二区| 欧美国产国产综合| 中文字幕一区在线观看| 亚洲精品国产视频| 强制捆绑调教一区二区| 毛片av一区二区| 国产精品系列在线播放| 成人h版在线观看| 91猫先生在线| 制服丝袜亚洲精品中文字幕| 欧美成va人片在线观看| 国产午夜精品久久久久久久| 国产精品天美传媒沈樵| 亚洲激情中文1区| 爽好久久久欧美精品| 麻豆国产精品官网| 成人黄页在线观看| 欧美日韩一级黄| 久久嫩草精品久久久精品| 中文字幕一区二区5566日韩| 亚洲第一久久影院| 91国产免费观看| 欧美mv日韩mv亚洲| 成人免费小视频| 日本中文在线一区| 成人中文字幕在线| 欧美精品精品一区| 中文字幕一区日韩精品欧美| 午夜精品视频一区| 懂色av一区二区三区蜜臀| 欧美午夜精品久久久| 国产欧美日韩精品在线| 日韩中文字幕一区二区三区| 国产成人高清在线| 日韩一区二区三区观看| 亚洲色图视频网| 激情综合网最新| 欧美日韩精品一区二区天天拍小说| 精品99久久久久久| 亚洲高清免费在线| 波多野结衣欧美| 久久综合久久综合久久综合| 亚洲成国产人片在线观看| 成人激情动漫在线观看| 精品国产伦一区二区三区观看体验| 亚洲欧美另类综合偷拍| 国产69精品久久777的优势| 欧美一级在线观看| 亚洲国产三级在线| 色菇凉天天综合网| 国产精品久久午夜夜伦鲁鲁| 美国精品在线观看| 51精品秘密在线观看| 亚洲免费高清视频在线| 成人美女在线观看| 久久久不卡影院| 国产精品综合网| 精品乱人伦小说| 另类人妖一区二区av| 欧美挠脚心视频网站| 亚洲成a天堂v人片| 在线免费观看成人短视频| 亚洲视频在线一区观看| 91无套直看片红桃| 国产精品免费丝袜| av午夜一区麻豆| 中文字幕一区二区三区视频| av网站一区二区三区| 中文字幕在线观看不卡| 一本久道中文字幕精品亚洲嫩| 国产精品视频九色porn| 91麻豆免费观看| 亚洲最色的网站| 777久久久精品| 精品一区二区久久久| 久久久777精品电影网影网| 国产91在线看| 亚洲天堂2014| 欧美日韩夫妻久久| 美女视频一区二区三区| 久久久美女毛片| 成人午夜视频在线观看| 亚洲免费观看高清完整版在线观看| 色域天天综合网| 亚洲国产视频一区| 精品少妇一区二区三区免费观看| 制服视频三区第一页精品| 天堂成人国产精品一区| 精品国产乱码久久久久久蜜臀| 国产成人激情av| 亚洲午夜在线视频| 欧美zozozo| av激情亚洲男人天堂| 午夜免费欧美电影| 日本一区二区视频在线| 欧洲视频一区二区| 狠狠色狠狠色合久久伊人| 国产精品萝li| 91精品国产一区二区三区蜜臀| 国产激情一区二区三区| 一卡二卡欧美日韩| 久久久精品黄色| 欧美少妇一区二区| 福利电影一区二区| 天堂成人免费av电影一区| 国产视频911| 欧美精品久久一区二区三区| 成人美女视频在线看| 亚洲成人福利片| 国产精品伦理一区二区| 日韩色视频在线观看| 91亚洲精品久久久蜜桃网站| 奇米在线7777在线精品| 亚洲欧美视频在线观看| 久久色成人在线| 67194成人在线观看| 99精品桃花视频在线观看| 国内国产精品久久| 婷婷丁香久久五月婷婷| 国产精品理伦片| 精品国产自在久精品国产| 欧美三区免费完整视频在线观看| 懂色av中文一区二区三区| 九九精品一区二区| 午夜欧美电影在线观看| 一卡二卡三卡日韩欧美| 中文字幕一区二区三区精华液| 精品欧美乱码久久久久久| 欧美放荡的少妇| 欧美在线视频全部完| 色综合天天综合色综合av | 色综合久久久网| 国产精品456| 国内精品久久久久影院一蜜桃| 一区二区三区四区av| 国产精品国产三级国产普通话99| 精品剧情v国产在线观看在线| 这里只有精品视频在线观看| 欧美在线视频全部完| 色8久久人人97超碰香蕉987| 99视频一区二区| 99综合电影在线视频| 成人av高清在线| 99国产精品久久久久久久久久| av电影在线观看不卡| 97se亚洲国产综合自在线观| 91影院在线观看| 欧美网站一区二区| 91精品在线观看入口| 欧美一级免费观看| 制服视频三区第一页精品| 日韩视频在线观看一区二区| 日韩精品综合一本久道在线视频| 日韩精品中文字幕在线一区| 久久亚洲免费视频| 亚洲国产高清aⅴ视频| 一区二区中文视频| 亚洲国产精品一区二区久久| 亚洲一区精品在线| 日本色综合中文字幕| 另类小说图片综合网| 国产精品一区免费在线观看| 成人激情校园春色| 欧美日韩国产区一| 精品久久久久久久久久久院品网| 欧美精品一区二区在线观看| 经典三级在线一区| 成人高清视频在线| 欧美日韩小视频| 精品久久久久久久久久久久包黑料 | 全部av―极品视觉盛宴亚洲| 久久国产人妖系列| 99视频国产精品| 欧美精品视频www在线观看| 日韩精品一区国产麻豆| 中文字幕av一区二区三区| 一区二区三区国产精品| 国内一区二区视频| 日本高清不卡视频| 日韩精品自拍偷拍| 亚洲免费观看高清| 国内精品国产三级国产a久久| 91网站在线观看视频| 91精品国产麻豆| 亚洲日本乱码在线观看| 久久国产精品99久久久久久老狼| 成人av午夜电影| 精品久久人人做人人爽| 亚洲精品美国一| 国内精品写真在线观看| 欧美日韩在线播放一区| 国产精品久久久久久久久免费樱桃| 午夜激情一区二区| 91网站视频在线观看| 久久久国产综合精品女国产盗摄| 亚洲成人动漫精品|