SMTPTransport和带有特殊字符的电子邮件

时间:2014-11-14 18:55:55

标签: java spring email javamail

我正在使用Spring和JavaMailSenderImpl发送电子邮件。但是当我尝试将电子邮件发送到带有特殊字符的电子邮件地址时(conceição-fake@gmail.com),我收到以下错误:

nested exception is:
 com.sun.mail.smtp.SMTPAddressFailedException: 554 5.1.1 concei  o-fake@gmail.com>: Recipient address rejected: User unknown in local recipient table
 org.springframework.mail.MailSendException: Failed messages: javax.mail.SendFailedException: Invalid Addresses;
nested exception is: 
 com.sun.mail.smtp.SMTPAddressFailedException: 554 5.1.1 concei  o-fake@gmail.com>: 
 Recipient address rejected: User unknown in local recipient table
; message exception details (1) are:
Failed message 1:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 554 5.1.1 concei  o-fake@gmail.com>: 
Recipient address rejected: User unknown in local recipient table

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1294)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:635)

我的JavaMailSenderImpl配置是:

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="defaultEncoding" value="UTF-8" />
    <property name="host">
        <value>${application.mail.host}</value>
    </property>
    <property name="port">
        <value>${application.mail.port}</value>
    </property>
    <property name="username">
        <value>${application.mail.username}</value>
    </property>
    <property name="password">
        <value>${application.mail.password}</value>
    </property>
    <property name="javaMailProperties">
        <props>
            <prop key="mail.mime.charset">UTF-8</prop>
        </props>
    </property>
</bean>

我正在使用MimeMessage。

我错过了什么?

修改

我认为问题在于:

protected void sendCommand(String cmd) throws MessagingException {
    sendCommand(ASCIIUtility.getBytes(cmd));
}

代码将地址发送到邮件服务器,但是当它转换为字节时,不考虑非ASCII字符。

因此无法使用Spring Framework将电子邮件发送到具有特殊字符的地址?

1 个答案:

答案 0 :(得分:0)

我的邮件服务器不符合RFC6530。