Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bc6f4e78e | |||
| 9bfc4d9ae9 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
[submodule "libetpan"]
|
||||
path = libetpan
|
||||
url = https://github.com/dinhviethoa/libetpan.git
|
||||
url = https://github.com/mronge/libetpan.git
|
||||
[submodule "iOSPorts"]
|
||||
path = iOSPorts
|
||||
url = https://github.com/mronge/iOSPorts.git
|
||||
|
||||
@@ -95,6 +95,9 @@
|
||||
self.lastError = MailCoreCreateErrorFromIMAPCode(err);
|
||||
return NO;
|
||||
}
|
||||
|
||||
struct imap_mailstorage *imap_storage = myStorage->sto_data;
|
||||
imap_storage->imap_auth_type = authType;
|
||||
|
||||
err = mailstorage_connect(myStorage);
|
||||
if (err == MAIL_ERROR_LOGIN) {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
- (BOOL)helo;
|
||||
- (BOOL)startTLS;
|
||||
- (BOOL)authenticateWithUsername:(NSString *)username password:(NSString *)password server:(NSString *)server;
|
||||
- (BOOL)authenticateWithUsername:(NSString *)username oauth2Token:(NSString *)oauthToken;
|
||||
- (BOOL)setFrom:(NSString *)fromAddress;
|
||||
- (BOOL)setRecipientAddress:(NSString *)recAddress;
|
||||
@end
|
||||
|
||||
@@ -162,6 +162,19 @@ static int fill_local_ip_port(mailstream * stream, char * local_ip_port, size_t
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)authenticateWithUsername:(NSString *)username oauth2Token:(NSString *)oauthToken {
|
||||
char *cUsername = (char *)[username cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
char *cToken = (char *)[oauthToken cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
int r = mailsmtp_oauth2_authenticate([self resource], cUsername, cToken);
|
||||
|
||||
if (r != MAIL_NO_ERROR) {
|
||||
self.lastError = MailCoreCreateErrorFromSMTPCode(r);
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)setFrom:(NSString *)fromAddress {
|
||||
int ret = mailesmtp_mail([self resource], [fromAddress cStringUsingEncoding:NSUTF8StringEncoding], 1, "MailCoreSMTP");
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
- (BOOL)helo;
|
||||
- (BOOL)startTLS;
|
||||
- (BOOL)authenticateWithUsername:(NSString *)username password:(NSString *)password server:(NSString *)server;
|
||||
- (BOOL)authenticateWithUsername:(NSString *)username oauth2Token:(NSString *)oauthToken;
|
||||
- (BOOL)setFrom:(NSString *)fromAddress;
|
||||
- (BOOL)setRecipients:(id)recipients;
|
||||
- (BOOL)setRecipientAddress:(NSString *)recAddress;
|
||||
|
||||
@@ -89,6 +89,10 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)authenticateWithUsername:(NSString *)username oauth2Token:(NSString *)oauthToken {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)setFrom:(NSString *)fromAddress {
|
||||
int ret = mailsmtp_mail([self resource], [fromAddress cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
if (ret != MAIL_NO_ERROR) {
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
@param password The password, if there is none then pass in an empty string.
|
||||
@param port The port to use, the standard port is 25
|
||||
@param connectionType What kind of connection, either: CTSMTPConnectionTypePlain, CTSMTPConnectionTypeStartTLS, CTSMTPConnectionTypeTLS
|
||||
@param auth Pass in YES if you would like to use SASL authentication
|
||||
@param authType None, Password, or OAuth2
|
||||
@param error Will contain an error when the method returns NO
|
||||
@return Returns YES on success, NO on error
|
||||
*/
|
||||
@@ -61,7 +61,7 @@
|
||||
password:(NSString *)password
|
||||
port:(unsigned int)port
|
||||
connectionType:(CTSMTPConnectionType)connectionType
|
||||
useAuth:(BOOL)auth
|
||||
authType:(CTSMTPAuthType)authType
|
||||
error:(NSError **)error;
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
@implementation CTSMTPConnection
|
||||
+ (BOOL)sendMessage:(CTCoreMessage *)message server:(NSString *)server username:(NSString *)username
|
||||
password:(NSString *)password port:(unsigned int)port connectionType:(CTSMTPConnectionType)connectionType
|
||||
useAuth:(BOOL)auth error:(NSError **)error {
|
||||
authType:(CTSMTPAuthType)authType error:(NSError **)error {
|
||||
BOOL success;
|
||||
mailsmtp *smtp = NULL;
|
||||
smtp = mailsmtp_new(0, NULL);
|
||||
@@ -71,11 +71,16 @@
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (auth) {
|
||||
if (authType == CTSMTPAuthTypePassword) {
|
||||
success = [smtpObj authenticateWithUsername:username password:password server:server];
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
} else if (authType == CTSMTPAuthTypeOauth2) {
|
||||
success = [smtpObj authenticateWithUsername:username oauth2Token:password];
|
||||
if (!success) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
success = [smtpObj setFrom:[[[message from] anyObject] email]];
|
||||
|
||||
@@ -70,6 +70,12 @@ typedef enum {
|
||||
|
||||
#define CTImapAuthTypePlain IMAP_AUTH_TYPE_PLAIN
|
||||
|
||||
typedef enum {
|
||||
CTSMTPAuthTypeNone = 0,
|
||||
CTSMTPAuthTypePassword,
|
||||
CTSMTPAuthTypeOauth2,
|
||||
} CTSMTPAuthType;
|
||||
|
||||
/** List of Message Flags **/
|
||||
|
||||
#define CTFlagNew MAIL_FLAG_NEW
|
||||
|
||||
+1
-1
Submodule libetpan updated: fb73212f4d...509f6b8d06
Reference in New Issue
Block a user