用SMTPClient检查邮件是否在VB.NET中成功发送(Check if mail was successfully sent in VB.NET with SMTPClient)
我正在尝试创建一个将电子邮件发送到smtp服务器的应用程序。
服务器未设置为固定,但会根据电子邮件应发送到的电子邮件地址的域部分进行查找。
例:
发邮件至:test@stackoverflow.com
域部分:stackoverflow.com
MX记录查找的结果(命令行“nslookup -type = mx stackoverflow.com”:
MX首选项= 30,邮件交换器= stackoverflow.com.sgb.compsoverflow.com MX首选项= 40,邮件交换器= stackoverflow.com.s9b2.psmtp.com stackoverflow.com MX首选项= 10,邮件交换器MX preference = 20,邮件交换器= stackoverflow.com.s9a2.psmtp.com
知道邮件服务器是否接受邮件并且邮件已成功发送将非常有用。
到目前为止,我能够通过使用System.Net.Mail.SMTPClient对象及其SendAsync函数获取SMTP-Server错误代码(如果发生错误(StatusCode 5xx)),那么,如果有错误,我在SMTPClient的回调事件中获得一个Exception-Object
我很清楚,并非每个邮件服务器都会告诉我mailaccount是否真正存在,然后用错误代码拒绝我的邮件,而只是接受邮件并删除邮件。 因此,我会很感激另一种方法来检查邮件是否被发送(注意:没有阅读,这将是阅读确认)
最终目的是:尝试使用域名mailserver向收件人发送电子邮件,如果失败,请根据错误代码(用户不存在 - > abort / mailserver未响应 - >使用另一个邮件服务器(如果可用))继续操作。
预先感谢(并对错别字:)))
I'm trying to create an application that sends an email to an smtp-server.
The server is not set fixed, but will be looked up according to the domainpart of the email-address where the email should be sent to.
Example:
Email To: test@stackoverflow.com
Domain-Part: stackoverflow.com
Result of a MX-Record Lookup (commandline "nslookup -type=mx stackoverflow.com":
stackoverflow.com MX preference = 30, mail exchanger = stackoverflow.com.s9b1.psmtp.com stackoverflow.com MX preference = 40, mail exchanger = stackoverflow.com.s9b2.psmtp.com stackoverflow.com MX preference = 10, mail exchanger = stackoverflow.com.s9a1.psmtp.com stackoverflow.com MX preference = 20, mail exchanger = stackoverflow.com.s9a2.psmtp.com
It would be quite useful, to know if the message was accepted by the mailserver and the message was successfully sent.
What I am able so far is, that I can get the SMTP-Server error code (if there was an error (StatusCode 5xx) by using the System.Net.Mail.SMTPClient Object and its SendAsync Function. There, if there was an error, I get an Exception-Object in the Callback-Event of the SMTPClient
I'm well aware that not every mailserver will tell me if the mailaccount truly exists and then reject my mail with an errorcode but instead just accept the message and then delete it. Therefore I would be grateful for another Method to check if the mail was sent (note: not read, that would be the read confirmation)
The final purpose would be: Try to send an email to a recipient using it's domains mailserver and if it fails, proceed according to the errorcode (user does not exist -> abort / mailserver did not respond -> use another mailserver if available).
Thanks in advance (and sorry for typos :))
原文:https://stackoverflow.com/questions/6679766
最满意答案
定义一个新的方法来推送你的详细视图控制器,并使用-performSelectorOnMainThread:withObject:waitUntilDone:在主线程上执行它。 不要尝试从其他线程进行任何UI更改。
Define a new method to push your detail view controller and use -performSelectorOnMainThread:withObject:waitUntilDone: to perform it on the main thread. Don't try to make any UI changes from other threads.
相关问答
更多-
“此应用程序正在修改自动布局引擎”错误(Swift iOS)(“This application is modifying the autolayout engine” error (Swift iOS))[2022-11-06]
尝试这个: FIRAuth.auth()?.sendPasswordResetWithEmail(userEnteredEmail!, completion: { error in dispatch_async(dispatch_get_main_queue(), { if error != nil { //Tell user that the user name or password is incorrect. let errorCode = error!.code ... -
定义一个新的方法来推送你的详细视图控制器,并使用-performSelectorOnMainThread:withObject:waitUntilDone:在主线程上执行它。 不要尝试从其他线程进行任何UI更改。 Define a new method to push your detail view controller and use -performSelectorOnMainThread:withObject:waitUntilDone: to perform it on the main thre ...
-
iOS中的范围和线程(Scope and threading in iOS)[2022-02-05]
使用dispatch_async ,该位代码不会阻塞。 这意味着在fetchedData之前触发了数组计数日志语句,因此您的字典和数组仍为空。 查看日志语句的顺序 - 在记录字典之前应该看到数组计数。 // Executes on another thread. ViewDidLoad will continue to run. dispatch_async(kBgAdsQueue, ^{ NSData *data = [NSData dataWithContentsOfURL:url]; ... -
最简洁的答案是不。 DynamoDB是一个无模式存储。 在读取期间:如果客户端的AWSDynamoDBObjectModel具有比AWSDynamoDBObjectModel中的属性更多的属性,反之亦然,则会忽略额外的属性。 写入期间:这里记录了4种不同的保存行为选项。 默认的AWSDynamoDBObjectMapperSaveBehaviorUpdate会使未建模的属性不受影响,并且对于您的用例应该可以正常工作。 The short answer is, no. DynamoDB is a schema ...
-
根据文件 : - (void)addAnimation:(CAAnimation *)anim forKey:(NSString *)key 将动画对象添加到接收器的渲染树中以获取指定的键。 参数anim : 要添加到渲染树的动画。 请注意,对象由渲染树复制,未引用。 对对象的任何后续修改都不会传播到渲染树中。 所以我认为重用相同的CAAnimation对象是安全的。 According to the docs: - (void)addAnimation:(CAAnimation *)anim forKey ...
-
CoreData线程。(CoreData Threading. iOS 6 vs 7)[2023-08-22]
我没有在iOS 6上使用过两个NSPersistentStoreCoordinators ,但在WWDC期间明确提到了来自不同商店协调员的上下文之间的合并更改,因此我认为它在iOS 7中已更改。请参阅以下会话: 207 - Core核心数据有什么新功能(从幻灯片编号145开始)。 211 - 核心数据性能(从幻灯片编号91开始), I haven't been using two NSPersistentStoreCoordinators on iOS 6, but merging changes betw ... -
多线程策略?(Multi-threading strategies? (Modifying a scene in a multi-threaded engine through an Editor))[2023-07-10]
除了@lassevk建议的两阶段过程之外,您还可以使用管道结构将命令“推送”到渲染器,以便这些更改获取渲染引擎的另一个工作项的形式。 例如,假设您的引擎遵循如下工作流程: 计算职位 过程物理 过程灯过程摄像头 渲染场景 您可以将新项目添加到位置0中的工作流程中,称为“过程更改”,它从管道中提取信息并将其合并到场景中。 In addition to the two-stage process suggested by @lassevk you could use a Pipe structure to "pu ... -
合作线程,没有任务(Cooperative Threading, No assignment)[2023-01-08]
不确定你正在使用哪个实现,但是我无法获得无限循环,只是取消注释表达式。 (我使用了几个R6RS实现,包括Racket。) 为了简化操作,我删除了你的代码: #!r6rs (import (rnrs)) (define (print . args) (for-each display args) (newline)) (let ((spawn-thread (lambda (it . args) (call/cc (apply it args)))) (main ... -
COM多线程支持(COM multi-threading support)[2022-03-04]
到目前为止,评论和答案中存在相当大的混淆。 STA或MTA是线程的属性。 但重要的是COM组件需要什么。 这是在ThreadingModel注册表值中声明的。 你找到了“公寓”,这是一个非常常见的环境。 这意味着该组件不支持线程。 这与.NET框架中的绝大多数类没有什么不同,很少有线程安全的。 最大的区别是COM 强制执行线程安全。 使用.NET类,您可以编写代码,以便以线程安全的方式使用类对象。 这很难做到正确并且是一个非常难以诊断的错误来源,但设计良好的锁定可以让你绕过限制。 这是不可能的COM,它将始 ... -
iOS应用中的线程问题(Threading issue in iOS app)[2021-11-06]
您应该在主线程上执行GUI相关任务,在要更新textview值的代码周围添加主队列/线程块。 ispatch_queue_t que = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(que, ^{ thisRiverGauge = [[RiverGauge alloc] initWithStationInfo:gauge forHistoryInHours:5 inThisFormat:@ ...