Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
sendmail - sendmail.c

sendmail.c

Caricato da: ScorpionITA
Scarica il programma completo

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <winsock.h>
  4. #include <windows.h>
  5.  
  6. typedef char stringa[500];
  7.  
  8. SOCKET conn;
  9. FILE *fmail;
  10. int lun, err=0;
  11. int time=0;
  12. char buf[1500],end[7];
  13. char input;
  14. char Mittente[50]="";
  15. char Destinatario[50]="";
  16. char Oggetto[50]="";
  17. SOCKADDR_IN conn_addr;
  18. WSADATA data;
  19. WORD versione;
  20. LPHOSTENT host;
  21.  
  22.  
  23.  
  24. void RispostaServer();
  25. void inviomail();
  26.  
  27. int main(int argc,char **argv)
  28. {
  29.     printf("\n     @#####################################################@ ");
  30.     printf("\n     @####################@ Sendmail @####################@ ");
  31.     printf("\n     @##############################!By Scorpion Attack!###@ ");
  32.     printf("\n     @#####################################################@ \n\n\n");
  33.    
  34.     printf("\nNome/E-mail Mittente: ");
  35.     gets(Mittente);
  36.    
  37.     printf("\nE-mail Destinatario: ");
  38.     gets(Destinatario);
  39.      
  40.     printf("\nOggetto: ");
  41.     gets(Oggetto);
  42.    
  43.        
  44.    
  45.     printf ("Invio E-mail in corso...\n");
  46.     inviomail();
  47.     sleep(200);
  48.     WSACleanup();
  49.     system("cls");
  50.     printf("\n     @#####################################################@ ");
  51.     printf("\n     @####################@ Sendmail @####################@ ");
  52.     printf("\n     @##############################!By Scorpion Attack!###@ ");
  53.     printf("\n     @#####################################################@ \n\n\n");
  54.     printf("\nE-Mail inviata");
  55.     sleep(2500);
  56.     return 0;
  57. }
  58.  
  59. void inviomail(){
  60.      fmail=fopen("mail.txt","r");
  61.          if (fmail==NULL){
  62.                  printf("Errore file \"mail.txt\"");
  63.                 }
  64.      
  65.      versione=MAKEWORD(2,0);
  66.      WSAStartup(versione,&data);
  67.  
  68.          conn=socket(PF_INET,SOCK_STREAM,0);
  69.          conn_addr.sin_family=PF_INET;
  70.          conn_addr.sin_port=htons(25);
  71.  
  72.          host=gethostbyname ("mail.tin.it");
  73.          if (host==NULL){
  74.         err=WSAGetLastError();
  75.                 printf ("Errore con l'Host\t%d",err);
  76.                              }
  77.  
  78.          conn_addr.sin_addr = *((LPIN_ADDR)*host->h_addr_list);
  79.      lun=sizeof(struct sockaddr);
  80.      
  81.      err=connect(conn,(struct sockaddr*)&conn_addr,lun);
  82.          if (err!=0){
  83.                 err=WSAGetLastError();
  84.                 printf("Errore della Socket\t%d",err);
  85.                 }
  86.    
  87.     RispostaServer();
  88.        
  89.         sprintf(buf, "helo inviamail\nmail from:<sendmail@scorpionattack.it>\nrcpt to:<%s>\ndata\n",Destinatario);
  90.     send(conn, buf, strlen(buf), 0);
  91.    
  92.     RispostaServer();
  93.    
  94.     sprintf(buf, "From: %s\n",Mittente);
  95.     send(conn, buf, strlen(buf), 0);
  96.        
  97.     sprintf(buf, "To: %s\n",Destinatario);
  98.     send(conn, buf, strlen(buf), 0);
  99.    
  100.     sprintf(buf, "Subject: %s\n",Oggetto);
  101.     send(conn, buf, strlen(buf), 0);
  102.        
  103.        
  104.         while (feof(fmail)==0){
  105.                 fscanf (fmail,"%c",&input);
  106.                 send (conn,&input,1,0);
  107.                    }
  108.    
  109.     sprintf(buf, "\n.\n");
  110.     printf(buf);
  111.     send(conn, buf, strlen(buf), 0);
  112.    
  113.         fclose(fmail);
  114.  
  115.    
  116.         sprintf(end,"quit\n");
  117.         send(conn,end,strlen(end),0);
  118.    
  119.     RispostaServer();
  120.    
  121.    
  122.         closesocket(conn);
  123.    
  124.     }
  125.  
  126.  
  127. void RispostaServer(){
  128.  
  129.         char mess[1000];
  130.         int n=0;
  131.         n=recv(conn,mess,200,0);
  132.         mess[n]=0;
  133. }