Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java RCPT收件人:<;rcpt@host&燃气轮机;SMTP语法_Java_Smtp - Fatal编程技术网

Java RCPT收件人:<;rcpt@host&燃气轮机;SMTP语法

Java RCPT收件人:<;rcpt@host&燃气轮机;SMTP语法,java,smtp,Java,Smtp,我有一段代码无法成功执行,我无法理解原因 此功能: public void send(Envelope envelope) throws IOException { String CRLF = "\r\n"; sendCommand("MAIL FROM:"+ envelope.Sender + CRLF, 250); //error occuring here. "Return Code:500 #5.

我有一段代码无法成功执行,我无法理解原因

此功能:

public void send(Envelope envelope) throws IOException
{
        String CRLF = "\r\n";
    sendCommand("MAIL FROM:"+ envelope.Sender + CRLF, 250);
    
    //error occuring here. "Return Code:500 #5.5.1 command not recognized"
    sendCommand("RCPT TO:" + envelope.Recipient + CRLF, 250);
    sendCommand("DATA", 354);
    toServer.print(envelope.Message.Headers + CRLF);
    toServer.print(envelope.Message.Body + CRLF);
    toServer.print("." +CRLF);
}
上述代码调用此函数:

private void sendCommand(String command, int rc) throws IOException
{
    /* Write command to server */
    toServer.print(command + CRLF);
    
    /*read reply from server. */
    String line = fromServer.readLine();
    
    System.err.println("Request: " + command);
    System.err.println("Return Code:" + line);
    
    
    /*
     * Check that the server's reply code is the same as the parameter rc.
     * If not, throw an IOException.
     */
    if (!line.substring(0,3).equals(rc+""))
    {
        throw new IOException();
    }
}
信息是这样传送的:

Socket connection = new Socket(envelope.DestAddr, SMTP_PORT); 
    fromServer = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    toServer = new PrintStream(connection.getOutputStream());
我使用相同的From和To。由于某种原因,RCPT TO:命令遇到一个错误,它说:

“返回代码:未识别500#5.5.1命令”


EDIT:我确实通过telnet手动尝试了它们,您将添加
\r\n
两次,一次是在构建字符串时在
send()
中,一次是在
print()
调用中的
sendCommand()


第二个
\r\n
触发
500 5.5.1无法识别的命令。

您添加
\r\n
两次-在构建字符串时在
send()
中一次,在
print()
调用中在
sendCommand()
中一次


第二个
\r\n
触发
500 5.5.1无法识别的命令。

您是否以相同的顺序尝试了相同的命令bty在端口25上对主机进行Telnet?显然
信封。收件人
不是您认为的-您需要检查它。哪个。。。这是无效的。您似乎对手动键入的
有心理障碍;)我只是用两种方法测试了一下。邮件服务器足够智能,可以为我添加邮件,所以这显然不是问题所在。啊,我刚刚发现了。下面的答案:)您是否以相同的顺序尝试了相同的命令bty在端口25上远程登录主机?显然
信封。收件人
不是您所认为的-您需要检查它。哪个。。。这是无效的。您似乎对手动键入的
有心理障碍;)我只是用两种方法测试了一下。邮件服务器足够智能,可以为我添加邮件,所以这显然不是问题所在。啊,我刚刚发现了。答复如下:)