0
我正在使用MailCore2框架發送電子郵件。我不使用MFMailComposer,因爲要求 沒有任何電子郵件用戶界面。我們只是獲取電子郵件ID和點擊按鈕發送一些信息 到電子郵件地址。 這是下面提到使用mailCore2發送電子郵件,給出錯誤代碼= 30
func sendEmailToCustomer(emailid:String?)
{
let session : MCOSMTPSession = MCOSMTPSession()
session.hostname = "mail.***.com"
session.port = 25
session.connectionType = MCOConnectionType.clear
let builder = MCOMessageBuilder()
builder.header.from = MCOAddress(displayName: " iPad App", mailbox:"[email protected]")
builder.header.to = [MCOAddress(displayName: "iPad App", mailbox:emailid)]
builder.header.subject = "Email Link \(NSUserDefaults.standardUserDefaults().valueForKey("branch_id")!)"
builder.htmlBody = "Thanks for choosing . Here is link you wanted to have in your inbox \n \((webView.request?.URL?.absoluteString)!))"
let data = builder.data()
let sendOperation : MCOSMTPSendOperation = session.sendOperationWithData(data)
NSUserDefaults .standardUserDefaults().setValue(emailid, forKey: "Customer_EmailId")
sendOperation.start({
(error : NSError?) -> Void in
if(error != nil){
//Keep sending the email till it succeeds. needs to know for security reasons.
// self.sendEmailToCustomer(emailid)
print("customer email failed.\(error?.code) \(error)")
self.showAlertMessage(MESSAGE_EMAIL_Not_SENT, title:"Email Not Sent", actions: [UIAlertAction(title: "OK", style: .Default) {action in
}], withSound: false)
Crittercism.leaveBreadcrumb("customer email failed")
}
else{
//Email sent successfully.
print("Email sent successfully \(emailid)")
self.showAlertMessage(MESSAGE_EMAIL_SENT, title:"Email Sent", actions: [UIAlertAction(title: "OK", style: .Default) {action in
}], withSound: false)
}
})
}
我的代碼,當我「到」電子郵件是在組織,其工作的罰款。但如果我嘗試發送電子郵件到一些外部 帳戶,然後獲取錯誤'錯誤域= MCOErrorDomain代碼= 30' 我試着改變不同的端口,連接類型。沒有任何工作。請幫助
您可以使用connectionLogger來找出服務器發送的確切錯誤消息嗎? –
Connectionlogger:550 5.0.0 550拒絕外部中繼:[email protected] – Nitya
這是錯誤消息,我正在連接記錄器 – Nitya