浏览代码

Add port optional parameter

Pascal Peridont 19 年之前
父节点
当前提交
33dbbd7014
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      std/mtwin/mail/Smtp.hx

+ 5 - 3
std/mtwin/mail/Smtp.hx

@@ -5,13 +5,15 @@ import mtwin.mail.Exception;
 
 class Smtp {
 
-	public static function send( host : String, from : String, to : String, data : String ){
+	public static function send( host : String, from : String, to : String, data : String, ?port: Int ){
+		if( port == null ) port = 25;
+
 		var cnx = new Socket();
 		
 		try {
-			cnx.connect(Socket.resolve(host),25);
+			cnx.connect(Socket.resolve(host),port);
 		}catch( e : Dynamic ){
-			throw ConnectionError(hort,25);
+			throw ConnectionError(host,port);
 		}
 		
 		// get server init line