2015-04-23 115 views

回答

3

使用默認的Apple框架

,你可以做以下

    之一,它是不可能的
  1. 或者添加第三方框架(庫)到您的iOS應用程序,它將電子郵件發送功能添加到您的應用程序
    - 但即使在第你不能訪問系統電子郵件帳戶(這是你的沙箱外)
    ==>可能不是你想要的

  2. 或者你做一個直接的HTTP/FTP(無論協議)服務器有一個腳本運行那裏,不發送本身爲您的應用程序

2

問:應用程序可以發送電子郵件而不讓用戶知道電子郵件地址嗎?

答:不,不可以在不知道發件人的電子郵件地址的情況下在iOS系統中發送郵件。

但是,如果你想開發要收到反饋系統,我會建議你使用Parse SDK,在那裏你可以簡單地通過REST服務發送用戶的答覆解析服務器,並想使簡單的網頁或Android應用程序直接在您的設備上檢索這些反饋,而不會暴露您的電子郵件ID

0

只有通過創建自己的服務器端郵件功能纔有可能。你必須發送所有參數的請求,你可以設置,如電子郵件,郵件正文,主題等,服務器將發送郵件從你身邊。

這樣你就可以發送郵件沒有MFMailComposeViewController

沒有此功能,無需用戶干預即可從iOS應用程序以編程方式發送電子郵件,但無法使用任何Apple框架實施。這可能是一個越獄手機,但它永遠不會看到App Store的內部。

-1

1:添加MessageUI框架:

單擊項目 選擇「構建階段」 展開「鏈接二進制與圖書館」 點擊「+」,然後鍵入「消息」中找到「MessageUI」的框架,然後加。

2:在當前視圖控制器添加導入和實施協議:

  #import <MessageUI/MessageUI.h> 
    #import <MessageUI/MFMailComposeViewController.h> 
    @interface MyViewController : UIViewController<MFMailComposeViewControllerDelegate> 








-(void)sendEmail { 
      // From within your active view controller 
      if([MFMailComposeViewController canSendMail]) { 
       MFMailComposeViewController *mailCont = [[MFMailComposeViewController alloc] init]; 
       mailCont.mailComposeDelegate = self;  // Required to invoke mailComposeController when send 

       [mailCont setSubject:@"Email subject"]; 
       [mailCont setToRecipients:[NSArray arrayWithObject:@"[email protected]"]]; 
       [mailCont setMessageBody:@"Email message" isHTML:NO]; 

       [self presentViewController:mailCont animated:YES completion:nil]; 
      } 
     } 

     - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { 
      [controller dismissViewControllerAnimated:YES completion:nil]; 
    } 
+0

在<[email protected]>給你的電子郵件ID, – vijeesh

0

是的,你可以使用SMTP直通發送郵件。

對於這裏的圖書館之一,我們可以發送電子郵件知道user.For指這skpsmtpmessage圖書館。

更多細節代碼一旦插入庫代碼到項目中,然後按照下面的setps。

在.h文件中使用下面的代碼

#import <UIKit/UIKit.h> 
    #import "SKPSMTPMessage.h" 
    @interface mailTransferViewController : UIViewController &lt;SKPSMTPMessageDelegate&gt;{ 
     IBOutlet UITextField *emailField; 
    } 
    - (IBAction)sendMessageInBack:(id)anObject; 
    @end 

而下面的代碼.m文件包含。

- (IBAction)sendMessageInBack:(id)anObject{ 

    NSLog(@"Start Sending"); 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"sample.pdf"]; 
    NSData *dataObj = [NSData dataWithContentsOfFile:writableDBPath]; 
    SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init]; 
    testMsg.fromEmail = @"Yours mail ids"; 
    testMsg.toEmail = emailField.text;//sender mail id 
    testMsg.relayHost = @"smtp.gmail.com"; 
    testMsg.requiresAuth = YES; 
    testMsg.login = @"Your mail ids"; 
    testMsg.pass = @"Mail id password"; 
    testMsg.subject = @"Test application "; 
    testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS! 
    // Only do this for self-signed certs! 
    // testMsg.validateSSLChain = NO; 
    testMsg.delegate = self; 
    NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,@"Some text to include in body",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil]; 
    //Logic for attach file. 
// NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"sample.pdf\"",kSKPSMTPPartContentTypeKey,@"attachment;\r\n\tfilename=\"sample.pdf\"",kSKPSMTPPartContentDispositionKey,[dataObj encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil]; 
// NSLog(@"%@",vcfPart); 
// testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart,nil]; 
// testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart,nil]; 

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

我認爲您的問題已通過此解決方案解決。

相關問題