久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 ColdFusion 中以編程方式驗證郵件服務器連接

Verify mail server connection programmatically in ColdFusion(在 ColdFusion 中以編程方式驗證郵件服務器連接)
本文介紹了在 ColdFusion 中以編程方式驗證郵件服務器連接的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用自定義 SMTP 服務器,并希望在用戶輸入自己的服務器憑據時驗證連接.

I'm using custom SMTP servers and would like to verify the connection when user enters his own server credentials.

與 Adob??e CF 和 Railo 在添加郵件服務器時允許執行的檢查類型完全相同.

Exactly the same type of check as Adobe CF and Railo allow to do when adding mail server.

當然,這并不能保證 delivery 會正常工作,但至少要檢查輸入的服務器/用戶名/密碼是否有效.

Sure, this does not guarantee that delivery will be working, but at least to check that entered server/username/pass are valid.

我可以看到一種棘手的方法:嘗試使用 cfmail 發送電子郵件并檢查郵件日志.但我相信它可以做得更優雅.

I can see one tricky way: try to send the email with cfmail and check the mail log. But I believe that it can be done with more elegant.

標準 ACF/Railo 發行版中是否有任何 Java 庫可以幫助我?我將如何使用它們?非常感謝示例.

Is there any Java library available with standard ACF/Railo distro to help me? How would I use them? Examples are highly appreciated.

提前致謝.

請不要與存在的 Java 標記相混淆.CFML 中需要解決方案.雖然它可以使用一些 Java 庫(如果適用).

Please don't be confused with Java tag present. Solution needed in CFML. Though it can use some Java libraries, if applicable.

推薦答案

我認為 sfussenegger 的想法是對的.但是不是使用自定義身份驗證器,而是通過 connect(..) 進行身份驗證呢?只用gmail測試過.但它似乎工作.

I think sfussenegger has the right idea. But instead of using a custom authenticator, what about authenticating via connect(..)? Only tested with gmail. But it seems to work.

我用 CF9 &OBD成功.不幸的是,我在 Railo 上沒有運氣……真可惜.

I tested this with CF9 & OBD successfully. Unfortunately, I had no luck with Railo ... bummer.

已更新以添加缺少的mail.smtp.auth"屬性.它現在應該也可以與 Railo 一起正常工作了.

Updated to add the missing "mail.smtp.auth" property. It should now work correctly with Railo as well.

    //Java Version
    int port = 587;
    String host = "smtp.gmail.com";
    String user = "username@gmail.com";
    String pwd = "email password";

    try {
        Properties props = new Properties();
        // required for gmail 
        props.put("mail.smtp.starttls.enable","true");
        props.put("mail.smtp.auth", "true");
        // or use getDefaultInstance instance if desired...
        Session session = Session.getInstance(props, null);
        Transport transport = session.getTransport("smtp");
        transport.connect(host, port, user, pwd);
        transport.close();
        System.out.println("success");
     } 
     catch(AuthenticationFailedException e) {
           System.out.println("AuthenticationFailedException - for authentication failures");
           e.printStackTrace();
     }
     catch(MessagingException e) {
           System.out.println("for other failures");
           e.printStackTrace();
     }



<cfscript>
    //CF Version
    port = 587;
    host = "smtp.gmail.com";
    user = "username@gmail.com";
    pwd = "email password";

    try {
        props = createObject("java", "java.util.Properties").init();
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.auth", "true");
        // or use getDefaultInstance instance if desired...
        mailSession = createObject("java", "javax.mail.Session").getInstance(props, javacast("null", ""));
        transport = mailSession.getTransport("smtp");
        transport.connect(host, port, user, pwd);
        transport.close();
        WriteOutput("success");
     } 
     //for authentication failures
     catch(javax.mail.AuthenticationFailedException e) {
           WriteOutput("Error: "& e.type &" ** "& e.message);
     }
     // for other failures
     catch(javax.mail.MessagingException e) {
           WriteOutput("Error: "& e.type &" ** "& e.message);
     }
</cfscript>

這篇關于在 ColdFusion 中以編程方式驗證郵件服務器連接的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 一级做a爰片久久毛片 | 精品日本中文字幕 | 免费大黄视频 | 久久99精品久久久久久国产越南 | 91在线免费视频 | 成人一区二区三区在线观看 | 亚洲欧美日韩精品久久亚洲区 | 337p日本欧洲亚洲大胆 | 久久久久久国产免费视网址 | 亚洲精品视频一区 | 99久久久99久久国产片鸭王 | www精品美女久久久tv | 欧美视频一区二区三区 | 欧美高清视频 | 国内成人免费视频 | 91久色| 特级丰满少妇一级aaaa爱毛片 | 91成人精品视频 | 麻豆av网站 | 一区二区蜜桃 | 精品久久久久一区二区国产 | 欧美不卡| 欧美成人精品欧美一级 | 欧美精品在欧美一区二区少妇 | 黄色国产视频 | 成人黄色网址大全 | 久久久久久久久久性 | 操操日 | a黄毛片| 久久久成人免费视频 | 在线91| 激情欧美日韩一区二区 | 国产一级特黄真人毛片 | 精品视频一区二区 | 成人福利在线视频 | 国产一区在线免费观看 | 国产精品久久久久久久久婷婷 | 国产精品久久国产精品 | 亚洲国产精品99久久久久久久久 | 中文字幕国产高清 | 亚洲一区二区精品 |