簡體   English   中英

如何使用Google SMTP發送郵件(錯誤)

[英]How can I send mail using Google SMTP (an error)

我正在嘗試使用Google SMTP發送郵件。 並附上一張圖片,上面有我的代碼和我的錯誤。 我的代碼:-(IBAction)gonder:(id)sender {

SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"fromme@gmail.com";
testMsg.toEmail = @"tome@hotmail.com";
testMsg.relayHost = @"smtp.gmail.com";
testMsg.requiresAuth = YES;
testMsg.login = @"myadress@gmail.com";
testMsg.pass = @"mypass";
testMsg.subject = @"had";
//testMsg.bccEmail = @"to@hotmail.com";
testMsg.wantsSecure = YES; 
testMsg.delegate = self;

NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
                           @"FDDFAFAD",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];

NSString *vcfPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"vcf"];
NSData *vcfData = [NSData dataWithContentsOfFile:vcfPath];

NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"test.vcf\"",kSKPSMTPPartContentTypeKey,
                         @"attachment;\r\n\tfilename=\"test.vcf\"",kSKPSMTPPartContentDispositionKey,[vcfData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];

testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart,nil];

[testMsg send];

和我的錯誤

我的錯!

引發'NSException'實例后調用終止

你能幫助我嗎? 我需要將圖像附加到此代碼。

直接來自示例代碼:

http://code.google.com/p/skpsmtpmessage/source/browse/trunk/SMTPSender/Classes/SMTPSenderAppDelegate.m

testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS! 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM