簡體   English   中英

驗證電子郵件的主題行

[英]Validate subject line of an email message

電子郵件主題中的某些字符無效,會導致失敗,例如回車。 我接受主題行作為輸入。

是否有關於什么是有效電子郵件主題的明確描述? 我查看了我認為正確的 RFC規范,但找不到任何內容。

是否有任何 .Net 庫可以驗證/清理電子郵件主題行? 特別是在核心庫或MailKit 中有什么嗎?

只要確保沒有換行符或回車符。 這就是System.Net.Mail所做的。

//This is from the MailBnfHelper class of the System.Net.Mime namespace.
internal static bool HasCROrLF(string data)
    {
      for (int index = 0; index < data.Length; ++index)
      {
        if (data[index] == '\r' || data[index] == '\n')
          return true;
      }
      return false;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM