iPhone アプリで .txt が添付された短いメールを作成して送信しました。
添付ファイルの長さが約 10 行であれば、GMail は問題なく開きます。
20 行以上になると、GMail が停止し、添付ファイルを開くことも、添付ファイルをダウンロードすることも、メールを転送することさえできなくなります。
また、同じメールを同僚に送信し、同僚が Mac OS メール クライアントで開いた場合、すべて問題なく動作します。
たとえば、次はテキスト ファイルの内容です (この長さは GMail で問題なく開きます)。
ACCELEROMETER READINGS
-0.0724487,-0.941833,-0.235458,2009-07-11 15:18:46 -0700
-0.0724487,-0.941833,-0.271683,2009-07-11 15:18:47 -0700
-0.0724487,-0.923721,-0.253571,2009-07-11 15:18:48 -0700
-0.0543365,-0.923721,-0.326019,2009-07-11 15:18:49 -0700
-0.0724487,-0.959946,-0.181122,2009-07-11 15:18:50 -0700
-0.0543365,-0.923721,-0.253571,2009-07-11 15:18:51 -0700
-0.108673,-0.923721,-0.380356,2009-07-11 15:18:52 -0700
-0.0724487,-0.923721,-0.271683,2009-07-11 15:18:53 -0700
GPS READINGS
HEADING READINGS
211.421,2009-07-11 15:18:46 -0700
206.421,2009-07-11 15:18:49 -0700
184.421,2009-07-11 15:18:50 -0700
195.421,2009-07-11 15:18:51 -0700
198.421,2009-07-11 15:18:53 -0700
ファイルがこのサイズの 2 倍の場合、GMail はそれを処理できませんが、もう一度メールは処理できます。では、何が問題なのだろうか?以下のようにメールを作成しました。
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"founders@gmail.com";
testMsg.toEmail = @"andrewljohnson@trailbehind.com";
testMsg.relayHost = @"smtp3.webfaction.com";
testMsg.requiresAuth = YES;
testMsg.login = @"andrewljohnson";
testMsg.pass = @"********";
testMsg.subject = @"iPhone Instrument Readings";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
testMsg.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey, @"Hey Kevin,\nHere are some GPS readings for you to filter.\n\nLove, \nTrailBehind",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
NSData *fileData = [NSData dataWithContentsOfFile:fileName];
NSDictionary *attached = [NSDictionary dictionaryWithObjectsAndKeys:@"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"readings.txt\"",kSKPSMTPPartContentTypeKey, @"attachment;\r\n\tfilename=\"readings.txt\"",kSKPSMTPPartContentDispositionKey,[fileData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,attached,nil];
[testMsg send];