Pb to send email with attach file

I have a problem for send a mail with attach file :
I can send a simple mail with the first part (client.print("Heure : "):wink:
If i send the multipart content type like this :
client.print("Content-Type: multipart/mixed; boundary="===MixBoundary==="\r\n");
the mail is send but is not delivered.
Here is the code :

#include <SPI.h>
#include <WiFi.h>
#include <SD.h>



static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
File datatxt;
char inputChar;

char ssid[] = "Livebox";      //  your network SSID (name) 
char pass[] = "4276336E9E4";  

long rssi;
int temp =1;
int h =0;
int wait = 2000;

IPAddress servermail(193,252,22,86);

WiFiClient client;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
 pinMode(10, OUTPUT);
 
 status = WiFi.begin(ssid, pass);
 SD.begin(4)
}

void loop() {
 if(sendEmail())  {
          Serial.println("Email envoye");
          temp = 3600;
          h += 1;
        }
        else {
          Serial.println("Email non envoye");
        }
}		

byte sendEmail() {
  picture=SD.open("FICHIER.CSV",FILE_READ);
  byte thisByte = 0;
  byte respCode;
  

  if (client.connect(servermail,25)) {
    Serial.println("connecte au serveur mail");
  } 
  else {
    Serial.println("connection au serveur mail defectueuse ");
    return 0;
  }

client.print("EHLO ");
  client.print(adresse);
  client.print(" \r\n");    

  client.print("AUTH LOGIN\r\n");

   
  client.print("xxxx=\r\n");

  client.print("yyyy=\r\n");

  
  client.print("MAIL From: <zzz@orange.fr>\r\n");

  client.print("RCPT To: <ttt@calixo.net>\r\n");

  client.print("DATA\r\n");

  client.print("Subject: email test\r\n");
  
  client.print("To: You <ttt@calixo.net>\r\n");

  // change this
  client.print("From: Me <zzz@orange.fr>\r\n");

   
                    client.print("Content-Type: multipart/mixed; boundary=\"===__MixBoundary__===\"\r\n");
                    Serial.print("Content-Type: multipart/mixed; boundary=\"===__MixBoundary__===\"}\r\n");
                   
					client.print("MIME-version: 1.0\r\n"); 
                     client.print("--===__MixBoundary__===\r\n");
                     Serial.print("--===__MixBoundary__===\r\n");
                       
                      client.print("Content-Type: text/plain; charset=\"iso-8859-1\"\r\n");
                      client.print("Content-Transfert-Encoding: 7bit\r\n");
                      
                      Serial.print("Content-Type: text/plain; charset=\"iso-8859-1\"\r\n");
                      Serial.print("Content-Transfert-Encoding: 7bit\r\n");
                      
                      client.print("\r\n");
                      Serial.print("\r\n");
                                                                 
 
						client.print("Heure : ");
						client.print("\r\n");
  
					client.print("--===__MixBoundary__===\r\n");
                      
                     datatxt =SD.open("FICHIER.CSV",FILE_READ); 
                     client.print("Content-Type: application/csv; name=\"FICHIER.csv\"\r\n");
                     client.print("Content-Transfer-Encoding: base64\r\n");
                     client.print("Content-Disposition: attachment; filename=\"FICHIER.csv\"\r\n");              
                     client.print("Content-Description: \"Fichier annuel\"r\n");
                       client.print("\r\n");
                       encode();
                       datatxt.close();
                       client.print("--===__MixBoundary__===--\r\n");
                       delay(wait);
					   
	client.print("\r\n");
	client.print(".\r\n");

	client.print("QUIT\r\n");

    client.stop();
	
	void encodeblock(unsigned char in[3],unsigned char out[4],int len) {
 out[0]=cb64[in[0]>>2]; out[1]=cb64[((in[0]&0x03)<<4)|((in[1]&0xF0)>>4)];
 out[2]=(unsigned char) (len>1 ? cb64[((in[1]&0x0F)<<2)|((in[2]&0xC0)>>6)] : '=');
 out[3]=(unsigned char) (len>2 ? cb64[in[2]&0x3F] : '=');
}

void encode() {
 unsigned char in[3],out[4]; 
 int i,len,blocksout=0;
 
 while (datatxt.available()!=0) {
   len=0; 
   inputChar =datatxt.read();
     // Serial.println(inputChar);
     for (i=0;i<3;i++){ 
           in[i]=(unsigned char) datatxt.read(); 
               if (datatxt.available()!=0) len++; 
                     else in[i]=0;
     }
     if (len){
         encodeblock(in,out,len); 
          for(i=0;i<4;i++) client.write(out[i]); 
          //Serial.println(out[i]);
               blocksout++; }
     if (blocksout>=19||datatxt.available()==0){ 
         if (blocksout) client.print("\r\n");  blocksout=0; 
     }
  }
}

Can anyone help me

Thank's

How do you know the email was sent? You are not reading or displaying the messages from the email server.

Here is the wifi shield email server code. You might need to add you user and password (remember to read the response from the server as all the other sends).
http://playground.arduino.cc/Code/WiFiEmailClient

edit: If you try that type of send (not reading the server responses) with my email server, it will refuse the email with the error message "I don't send email for rude clients".

I have remove the "if(!eRcv()) return 0;" from the posted code but i have it.
The message from the server are here:

connecte au serveur mail
220 mwinf5d38 ME ESMTP server ready
250-mwinf5d38 hello [21.1.87.229], pleased to meet you
250-HELP
250-AUTH LOGIN PLAIN
250-SIZE 44000000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 OK
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.7.0 ... authentication succeeded
250 2.1.0 zzz@orange.fr sender ok
250 2.1.5 ttt@calixo.net recipient ok
354 enter mail, end with "." on a line by itself
Content-Type: multipart/mixed; boundary="===MixBoundary==="}
--===MixBoundary===
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfert-Encoding: 7bit

fin fic
250 2.0.0 n3He1p0074wtMCa033HfPW mail accepted for delivery
221 2.0.0 mwinf5d38 ME closing connection
deconnecte du serveur mail
Email envoye

He says : 250 2.0.0 n3He1p0074wtMCa033HfPW mail accepted for delivery

I have remove the "if(!eRcv()) return 0;" from the posted code but i have it.

Then how did you get the responses? The eRcv() function displays the server response.

But it is showing the email is sent. See if the email is in your spam folder. Sometimes my email sends end up there. And sometimes it takes a while to get the email.

If i send the mail myself, i have a reply on my mailbox that sais:

said: 554 5.6.0 Message contains invalid header

What can be invalid?

I tried this and it worked for my email server and client (Outlook Express). I use client.write so it won't translate any binary characters. I commented the start and end of the new code.

  client.write("Subject: Arduino email test\r\n");

// this is new  
  client.write("MIME-Version: 1.0\r\n");
  client.write("Content-Type: Multipart/mixed; boundary=frontier\r\n\r\n");
  
  client.write("--frontier\r\n");
  client.write("Content-Type: text/plain\r\n\r\n");
  
  client.write("This is from my Arduino!\r\n");

  client.write("--frontier\r\n");
  client.write("Content-Type: text/plain\r\n");
  client.write("Content-Disposition: attachment; filename=test.txt\r\n\r\n");

// this is where you would send your file
  client.write("This is a test\r\n");  

  client.write("--frontier--\r\n");

// end of new  
  client.write(".\r\n");

The pb whas that a blank line where necessary after this:

client.print("Content-Type: multipart/mixed; boundary="===MixBoundary==="\r\n");

the good line is

client.print("Content-Type: multipart/mixed; boundary="===MixBoundary==="\r\n\r\n");

Thank's for your help.