Beispiel #1
0
/*{{{  log_line -- log lines*/
void log_line(BITMAP *dst, int x0, int y0, int x1, int y1, int op)
{
  check_map(dst);
  if (do_save) {
    SEND_LINE(dst->id, x0, y0, x1, y1, op);
  }
}
bool AmSmtpClient::send_data(const vector<string>& hdrs, const AmMail& mail)
{
  string part_delim = "----=_NextPart_" 
    + int2str(int(time(NULL))) 
    + "_" + int2str(int(getpid()));

  for( vector<string>::const_iterator hdr_it = hdrs.begin();
       hdr_it != hdrs.end(); ++hdr_it )
    SEND_LINE(*hdr_it);

  SEND_LINE("MIME-Version: 1.0");

  if(!mail.attachements.empty()){
    SEND_LINE("Content-Type: multipart/mixed; ");
    SEND_LINE("      boundary=\"" + part_delim + "\"");
    SEND_LINE(""); // EoH
    SEND_LINE("--" + part_delim);
  }

  if(mail.charset.empty()){
    SEND_LINE("Content-Type: text/plain");
  }
  else {
    SEND_LINE("Content-Type: text/plain; ");
    SEND_LINE("      charset=\"" + mail.charset + "\"");
  }
  SEND_LINE(""); //EoH
  SEND_LINE(mail.body);


  for( Attachements::const_iterator att_it = mail.attachements.begin();
       att_it != mail.attachements.end(); ++att_it	) {
	
    SEND_LINE("--" + part_delim );
    if(!att_it->content_type.empty()){
      SEND_LINE("Content-Type: " + att_it->content_type);
    }
    else {
      SEND_LINE("Content-Type: application/octet-stream");
    }
    SEND_LINE("Content-Transfer-Encoding: base64");
	
    if(att_it->filename.empty()) {
      SEND_LINE("Content-Disposition: inline"); // | "attachement"
    }
    else {
      SEND_LINE("Content-Disposition: inline; "); // | "attachement"
      SEND_LINE("      filename=\"" + att_it->filename + "\"");
    }
    SEND_LINE(""); // EoH

    base64_encode_file(att_it->fp,sd);
    SEND_LINE(""); // base64_encode_file() doesn't generate any EoL
  }

  if(!mail.attachements.empty()){
    SEND_LINE("--" + part_delim + "--");
  }

  return false;
}