gpt4 book ai didi

objective-c - 无需 GUI 即可发送电子邮件

转载 作者:行者123 更新时间:2023-12-01 19:24:48 24 4
gpt4 key购买 nike

关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。












想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。

3年前关闭。




Improve this question




是否有任何框架可以让我在不通过 GUI 的情况下发送电子邮件?

最佳答案

添加 this框架到您的项目,然后使用我的 Swift 类:

class EmailSender : SKPSMTPMessageDelegate {

private init() {}

static let sharedInstance = EmailSender();

func sendEmail(email : String, subject : String, message : String) {
let EMAIL_FROM = "test@gmail.com";
let EMAIL_PASS = "TestPassword";
let SMTP_SERVER = "smtp.gmail.com";

let EMAIL_TO = email;

let emailMessage = SKPSMTPMessage();
emailMessage.delegate = self;
emailMessage.fromEmail = EMAIL_FROM;
emailMessage.toEmail = EMAIL_TO;
emailMessage.relayHost = SMTP_SERVER;
emailMessage.requiresAuth = true;
emailMessage.login = EMAIL_FROM;
emailMessage.pass = EMAIL_PASS;
emailMessage.subject = subject;

emailMessage.wantsSecure = true;

let plainMsg = [
kSKPSMTPPartContentTypeKey : "text/plain",
kSKPSMTPPartMessageKey : message,
kSKPSMTPPartContentTransferEncodingKey : "8bit"
];

emailMessage.parts = [plainMsg];
emailMessage.send();
}

//MARK SKPSMTPMessageDelegate

@objc func messageSent(_ message: SKPSMTPMessage!) {

}

@objc func messageFailed(_ message: SKPSMTPMessage!, error: Error!) {

}

}

关于objective-c - 无需 GUI 即可发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8274538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com