我在 iPhone 应用程序中创建并发送了一封带有 .txt 附件的简短电子邮件。
如果附件大约有 10 行长,GMail 可以很好地打开它。
如果超过 20 行左右,GMail 就会阻塞——它不会打开附件、下载附件,甚至不会转发电子邮件。
此外,如果我向我的同事发送相同的电子邮件并且他使用他的 Mac OS Mail 客户端打开它,那么一切正常。
例如下面是文本文件的内容(这个长度在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
如果文件是这个大小的两倍,GMail 无法处理它,但 Mail 再次可以。那么,可能是什么问题?我创建的电子邮件如下:
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];