小编Raj*_*aju的帖子

发送时发生异常,javax.mail.MessagingException:530 5.7.57 SMTP; 客户端未经过身份验证,无法在MAIL FROM期间发送匿名邮件

这仅适用于(smtp.office365.com)SMTP.

public int sendEmail(String fromName,String fromAddress,ArrayList toAddressList ,ArrayList ccAddressList,ArrayList bccAddressList,String subject,String message,String SmtpServerIP,String smtpUserName,String smtpPassword, ArrayList<String>  attachmentFilePath ){
        SMTP_HOST_NAME=SmtpServerIP;
        SMTP_AUTH_USER=smtpUserName;
        SMTP_AUTH_PWD=smtpPassword;
        String emailmultipart="true";
        String smtpHost=SmtpServerIP;
        //System.out.println("SmtpServerIP"+SmtpServerIP);

        System.out.println("fromName :"+fromName+":SmtpServerIP:"+SmtpServerIP+":smtpPassword:"+smtpPassword+":smtpUserName:"+smtpUserName);
        boolean debug = false;
        Properties props = new Properties();
        props.put("mail.smtp.starttls.enable","true"); 
        props.setProperty("mail.transport.protocol", "smtp");
        if(smtpHost==null){
          return -99; 
        }
        if(smtpHost.length()>0){
          //props.put("mail.smtp.host", smtpHost);
          props.setProperty("mail.host", smtpHost);
         }
        else
        { 
          return 1; 
        }//Error No SmtpHost name Found.
       /* if(smtpUserName!=null && smtpUserName.length()>0){
            props.setProperty("mail.user", smtpUserName);
        }
        if(smtpPassword!=null && smtpPassword.length()>0){
            props.setProperty("mail.password", smtpPassword);
        }*/
        Session session=null;

        if(smtpUserName!=null && smtpUserName.length()>0&&smtpPassword!=null && smtpPassword.length()>0){
            System.out.println("smtpUserName111111111111111"+smtpUserName); …
Run Code Online (Sandbox Code Playgroud)

java email

3
推荐指数
1
解决办法
6349
查看次数

标签 统计

email ×1

java ×1