553 sorry, you can't send mail to other domain这是什么错误啊?

解决方案 »

  1.   

    bengbeng24
    java是如何发送email的呀?
    提供示例代碼給大家看下。
    謝啦 
      

  2.   

    sun网站上下载JavaMailAPIProperties mailProps = new Properties();mailProps.put("mail.smtp.host", smtpHost); 
    mailProps.put("mail.pop3.host", pop3Host);
    mailProps.put("mail.smtp.auth", "true");Session session = Session.getInstance(mailProps, null);
    MimeMessage newMessage = new MimeMessage(this.session);
    newMessage.setFrom(new InternetAddress(this.email));
    newMessage.setRecipient(Message.RecipientType.TO,new InternetAddress(msg.getTos()));
    newMessage.setHeader("X-Mailer", "jpower");
    newMessage.setSubject(msg.getTopic());
    newMessage.setSentDate(new Date());
    SMTPTransport t =(SMTPTransport)session.getTransport("smtp");
    t.connect(smtpHost, smtpUser, smtpPassword);
    t.sendMessage(newMessage, newMessage.getAllRecipients());
      

  3.   

    stmp的错误代码:
        421 <domain> Service not available, closing transmission channel 括号内的主机无法提供正常服务,关闭传送管道,邮件将滞留在主机上 
      450 Requested mail action not taken: mailbox unavailable 所要求的邮件动作无法执行:邮件信箱无法提供服务,邮件将滞留在主机上 
      451 Requested action aborted: local error in processing 要求动作中断:本地端错误 
      452 Requested action not taken: insufficient system storage 要求动作无法执行:系统空间不足 
      550 Requested action not taken: mailbox unavailable 所要求动作无法执行:信箱不存在,邮件将退回给寄件者 
      551 User not local; please try <forward-path> 邮件伺服器知道使用者不属於本地端,将尝试括号内的转送路径 
      552 Requested mail action aborted: exceeded storage allocation 所要求的动作中断:超出所分配的储存空间,邮件将退回给寄件者 
      553 Requested action not taken: mailbox name not allowed 所要求的动作未执行:信箱不允许该动作执行 
      554 Transaction failed 传送失败 
      

  4.   

    发送邮件SendMailTest.javapackage com.niex.mail.javamail;
    import java.util.Date;
    import java.util.Properties;import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    public class SendMailTest {
        
        SendMailTest() {
        }
    /**
     * 发送邮件
     *
     */
        public void sendMail() {
            logger.debug("开始发送邮件");
            //配置属性
            Properties props = new Properties();
            props.put("mail.smtp.host", "MAILSTORE1");
            props.put("mail.smtp.auth", "true");
            props.put("mail.transpost.protocol", "smtp");
            //验证 (Authenticator为抽象类不能实例化)
            Authenticator sa = new SmtpAuthenticator("username", "password");        //获取session
            Session sendMailSession = Session.getInstance(props, sa);
            
            //设置调试模式
             //sendMailSession.setDebug(true);
            
            Transport transport;
            Message newMessage = new MimeMessage(sendMailSession);
            try {
                newMessage.setFrom(new InternetAddress("[email protected]"));
                newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
                newMessage.setSubject("javamail测试");
                newMessage.setSentDate(new Date());
                newMessage.setText("121");
                //得到transport:用于传输mail
                transport = sendMailSession.getTransport("smtp");
                //调试连接到邮件服务器
                transport.connect("MAILSTORE1","username","password");   
                //发送邮件
                Transport.send(newMessage);        } catch (MessagingException e) {
                logger.debug("发送邮件出错");
                logger.debug(e.toString());
            }
            logger.debug("完成发送邮件");
        }    public static void main(String[] args) {
            SendMailTest sbt = new SendMailTest();
            sbt.sendMail();
        }
    }
    邮件服务器权限验证SmtpAuthenticator.java
    package com.niex.mail.javamail;import javax.mail.Authenticator;
    import javax.mail.PasswordAuthentication;/**
     * 
     * @author 
     *
     */
    public class SmtpAuthenticator extends Authenticator {
        String userName;    String userPassword;    public SmtpAuthenticator(String userName, String userPassword) {
            this.userName = userName;
            this.userPassword = userPassword;
        }
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(userName, userPassword);
        }
    }
      

  5.   

    你可以在命令行下发一封邮件像这样:
    C:\Documents and Settings\Administrator>telnet smtp.sina.com.cn 25
    220 smtp.sina.com.cn ESMTP SINAMAIL (Postfix Rules!)
    ehlo it315
    250-smtp.sina.com.cn
    250-PIPELINING
    250-SIZE 19660800
    250-VRFY
    250-ETRN
    250-AUTH LOGIN
    250-AUTH=LOGIN
    250 8BITMIME
    auth login
    334 VXNlcm5hbWU6
    aXQzMTVfdGVzdA==
    334 UGFzc3dvcmQ6
    MTIzNDU2
    235 Authentication successful
    mail from:<[email protected]>
    250 Ok
    rcpt to:<[email protected]>
    250 Ok
    data
    354 End data with <CR><LF>.<CR><LF>
    from:[email protected]
    to:[email protected]
    subject:xjizhe li shi biao ti
    subject:xjizhe li shi biao tizhe li shi xin jian de nei rong !hehe,zhu yi xie wan l jiu fa yi ge .
    .
    250 Ok: queued as 40C843B5F3A
    好了,这样就完成了一封邮件的发送,注意用户名和密码都是要经过base64编码的,呵呵.