SMTP/POP3 个客户在 linux

SMTP/POP3 client in linux

我想在 linux 中开发一个 STMP/POP3 客户端(仅客户端)。我想使用数字证书加密数据(我将尝试提供端到端的安全性)。我还想创建一个简单的界面(带有文本字段、发送按钮、收件箱等)。我的问题是:我应该在 java(如果可能的话)还是在 C/C++ 中执行此操作(在这种情况下,我必须为界面使用一些工具 -> 例如 QT)。你怎么看? 我的第二个问题:如果您有任何 ideas/recommendation 或有用的链接(或任何对我有帮助的东西),我将不胜感激。

关于你的第一个问题

should i do this in java(if it's possible) or C/C++

你可以使用任何你觉得舒服的语言,如果你想要我的建议,我建议你使用 java,因为使用 Swing 或 Javafx 创建图形界面非常容易,而且有很多库可以可以帮助您实现目标。

关于你的第二个问题

if you have any ideas/recommendation or helpful links

您可以在本网站找到从头到尾指导您的有用教程:JavaMail API Tutorial - Tutorialspoint

这是一个简单的应用程序界面,开始使用 JavaFx 创建的项目。

Simple Application UI Using JavaFX Desktop Screen-shot

Main.java

package application;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.fxml.FXMLLoader;


public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("Email.fxml"));
            Scene scene = new Scene(root,400,400);
            scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

EmailController.java

package application;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class EmailController {

    @FXML
    private ResourceBundle resources;

    @FXML
    private URL location;

    @FXML
    private TextField fromField;

    @FXML
    private TextField toField;

    @FXML
    private TextField loginField;

    @FXML
    private PasswordField passwordField;

    @FXML
    private TextField subjectField;

    @FXML
    private TextArea messageField;

    @FXML
    private Button deleteButton;

    @FXML
    private Button sendButton;

    @FXML
    void initialize() {


    }
}

Email.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>


<fx:root type="AnchorPane" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.111" fx:controller="application.EmailController">
   <children>
      <Pane prefHeight="522.0" prefWidth="761.0">
         <children>
            <VBox prefHeight="522.0" prefWidth="761.0">
               <children>
                  <GridPane gridLinesVisible="true">
                    <columnConstraints>
                      <ColumnConstraints hgrow="SOMETIMES" maxWidth="328.0" minWidth="10.0" prefWidth="131.0" />
                      <ColumnConstraints hgrow="SOMETIMES" maxWidth="635.0" minWidth="10.0" prefWidth="630.0" />
                    </columnConstraints>
                    <rowConstraints>
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                        <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                    </rowConstraints>
                     <children>
                        <Label alignment="CENTER_RIGHT" prefHeight="23.0" prefWidth="136.0" text="From : ">
                           <font>
                              <Font name="Segoe UI" size="18.0" />
                           </font>
                        </Label>
                        <TextField fx:id="fromField" GridPane.columnIndex="1" />
                        <Label alignment="CENTER_RIGHT" prefHeight="17.0" prefWidth="134.0" text="To : " textAlignment="CENTER" GridPane.rowIndex="1">
                           <font>
                              <Font name="Segoe UI" size="18.0" />
                           </font>
                        </Label>
                        <Label alignment="CENTER_RIGHT" prefHeight="17.0" prefWidth="134.0" text="Login : " textAlignment="CENTER" GridPane.rowIndex="2">
                           <font>
                              <Font name="Segoe UI" size="18.0" />
                           </font>
                        </Label>
                        <TextField fx:id="toField" GridPane.columnIndex="1" GridPane.rowIndex="1" />
                        <TextField fx:id="loginField" GridPane.columnIndex="1" GridPane.rowIndex="2" />
                        <Label alignment="CENTER_RIGHT" prefHeight="17.0" prefWidth="134.0" text="Password : " textAlignment="CENTER" GridPane.rowIndex="3">
                           <font>
                              <Font name="Segoe UI" size="18.0" />
                           </font>
                        </Label>
                        <PasswordField fx:id="passwordField" GridPane.columnIndex="1" GridPane.rowIndex="3" />
                     </children>
                  </GridPane>
                  <GridPane prefHeight="240.0" prefWidth="681.0">
                    <columnConstraints>
                      <ColumnConstraints hgrow="SOMETIMES" maxWidth="659.0" minWidth="10.0" prefWidth="152.0" />
                      <ColumnConstraints hgrow="SOMETIMES" maxWidth="722.0" minWidth="10.0" prefWidth="609.0" />
                    </columnConstraints>
                    <rowConstraints>
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                      <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                        <RowConstraints />
                        <RowConstraints minHeight="10.0" prefHeight="30.0" />
                    </rowConstraints>
                     <children>
                        <Label alignment="CENTER_RIGHT" prefHeight="23.0" prefWidth="150.0" text="Subject : ">
                           <font>
                              <Font name="Segoe UI" size="18.0" />
                           </font>
                        </Label>
                        <TextField fx:id="subjectField" GridPane.columnIndex="1" />
                        <Label alignment="CENTER_RIGHT" prefHeight="23.0" prefWidth="150.0" text="Message : " GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.vgrow="ALWAYS">
                           <font>
                              <Font name="Segoe UI" size="18.0" />
                           </font>
                        </Label>
                        <TextArea fx:id="messageField" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.rowSpan="2">
                           <GridPane.margin>
                              <Insets top="10.0" />
                           </GridPane.margin>
                        </TextArea>
                     </children>
                     <VBox.margin>
                        <Insets left="30.0" right="30.0" top="20.0" />
                     </VBox.margin>
                  </GridPane>
                  <Pane prefHeight="200.0" prefWidth="200.0">
                     <children>
                        <Button fx:id="deleteButton" layoutX="220.0" layoutY="30.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="150.0" text="Delete">
                           <font>
                              <Font name="Segoe UI" size="24.0" />
                           </font>
                        </Button>
                        <Button fx:id="sendButton" layoutX="450.0" layoutY="30.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="150.0" text="SEND">
                           <font>
                              <Font name="Segoe UI" size="24.0" />
                           </font>
                        </Button>
                     </children>
                  </Pane>
               </children>
            </VBox>
         </children>
      </Pane>
   </children>
</fx:root>