I'm using SKPSMTPMessage to send emails from our app. This allows us to attach a picture to the email and have that image automatically sent without the user tapping the send button. This works perfectly to send images to email accounts. But, I've just tried to send an image to my cell phone via Verizon, and my colleagues cell via ATT, both as an MMS message using these formats 123456789@vzwpix.com and 1234567890@mms.att.com. The crazy thing is that the messages show up in my gmail sent items but are never delivered to the cell phones as an MMS. But, if I login to gmail and forward the exact same message to 123456789@vzwpix.com the message gets delivered without fail. The image size is also only about 42KB.
I'm very confused by this and I wonder if perhaps I'm not formatting a message in a way that gmail can understand and therefore gmail is unable to properly deliver the message to a phone. Here is the code I'm using to compose the email
SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@emUsername_key", preset]];
testMsg.toEmail = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@toEmail_key", preset]];
testMsg.relayHost = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@emailServer_key", preset]];
testMsg.port = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@emailPort_key", preset]];
testMsg.requiresAuth = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@requiresAuth_key", preset]];
testMsg.login = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@emUsername_key", preset]];
testMsg.pass = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@emPassword_key", preset]];
testMsg.subject = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@emailSubject_key", preset]];
testMsg.wantsSecure = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:@"%@secureEmail_key", preset]];
NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber * customPort = [f numberFromString:testMsg.port];
defaultPorts = [[NSArray alloc] initWithObjects:customPort, [NSNumber numberWithShort:587], [NSNumber numberWithShort:25], [NSNumber numberWithShort:465], nil];
[f release];
testMsg.relayPorts = defaultPorts;
testMsg.delegate = self;
NSString *image_path = [NSString stringWithFormat:@"%@/%@", dir, file];
NSData *imageData1 = [NSData dataWithContentsOfFile:image_path];// sendImage is a UIImage *sendImage which contains original image and I defined it in Global.h
NSString* theFileExt = [[file lastPathComponent] pathExtension];
NSString *fileTitle1;
NSString *fileTitle2 = [NSString stringWithFormat:@"attachment;\r\n\tfilename=\"%@\"", title];
NSDictionary *vcfPart;
if([theFileExt compare:@"png"] == NSOrderedSame){
fileTitle1 = [NSString stringWithFormat:@"image/png;\r\n\tx-unix-mode=0644;\r\n\tname=\"%@\"", title];
}else if([theFileExt compare:@"jpg"] == NSOrderedSame){
fileTitle1 = [NSString stringWithFormat:@"image/jpg;\r\n\tx-unix-mode=0644;\r\n\tname=\"%@\"", title];
}
encodedString = nil;
size_t outBufferEstLength = EstimateBas64EncodedDataSize([imageData1 length]) + 1;
char *outBuffer = calloc(outBufferEstLength, sizeof(char));
size_t outBufferLength = outBufferEstLength;
if (Base64EncodeData([imageData1 bytes], [imageData1 length], outBuffer, &outBufferLength))
{
encodedString = [NSString stringWithCString:outBuffer encoding:NSASCIIStringEncoding];
}
else
{
[NSException raise:@"NSData+Base64AdditionsException" format:@"Unable to encode data!"];
}
free(outBuffer);
vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:fileTitle1,kSKPSMTPPartContentTypeKey,
fileTitle2,kSKPSMTPPartContentDispositionKey,encodedString,kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];
NSString * bodyMessage = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"%@emailSignature_key", preset]];
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
bodyMessage ,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart,nil];
[testMsg send];
[encodedString release];
And here is the header generated and displayed when checking the message contents on gmail
Return-Path: <myACCT@gmail.com>
Received: from localhost (000.sub-000-000-000.myvzw.com. [000.000.000.000])
by mx.google.com with ESMTPS id lotsOfStoof.0.2013.01.06.15.22.03
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 06 Jan 2013 15:22:05 -0800 (PST)
Message-ID: <some.stuff.here.kids@mx.google.com>
Date: Sun, 06 Jan 2013 15:22:05 -0800 (PST)
From: myACCT@gmail.com
To: 123456789@vzwpix.com
Content-Type: multipart/mixed; boundary=SKPSMTPMessage--Separator--Delimiter
Mime-Version: 1.0 (SKPSMTPMessage 1.0)
Subject: MYAPP!
--SKPSMTPMessage--Separator--Delimiter
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Sent from MYAPP. Get it on iTunes!
--SKPSMTPMessage--Separator--Delimiter
Content-Disposition: attachment;
filename="MYAPPIMAGENAME"
Content-Type: image/jpg;
x-unix-mode=0644;
name="MYAPPIMAGENAME"
Content-Transfer-Encoding: base64
Any guidance would be great. Thanks in advance!
EDIT: I've been messing with this issue and still can't figure out what would cause this. I know gmail can relay messages. What am I missing?
Thanks