>  Q&A  >  본문

用Java写发送邮件的程序,经常被当做垃圾邮件处理怎么解决

 sendMail(String receiver,String content){
       Properties properties=new Properties();
       properties.setProperty("mail.smtp.auth","true");
       properties.setProperty("mail.transport.protocol","smtp");
       properties.setProperty("mail.host","smtp.163.com");
       
       Session session =Session.getInstance(properties,new Authenticator(){
             protected PasswordAuthentication getPasswordAuthentication() {
             return new PasswordAuthentication("*********163.com","*******");
               }
          }
       );
      
      Message message=new MimeMessage(session);
try {
      message.setFrom(new InternetAddress("*********”@163.com"));
    } catch (AddressException e) {
      return "邮箱的登录失败,请检查你的账户密码是否正确!";
    } catch (MessagingException e) {
      return "你的账户异常,请重新发送!";
    }

try {
      message.addRecipients(RecipientType.TO,InternetAddress.parse(receiver));
      message.setSubject("MachineEye");
      message.setText(content);
    } catch (AddressException e1) {
      return "收件人账户信息不正确!";
    } catch (MessagingException e1) {
      return "收件人账户异常!";
    }
    
try {
      Transport.send(message);
    } catch (MessagingException e) {
      return "邮件发送失败";
    }
return "发送成功!";
}
PHPzPHPz2744일 전713

모든 응답(3)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-18 10:50:04

    ....어떤 언어로 작성하더라도 이메일 주소의 적법성과 권위가 인정되지 않거나, 내용이 약간 틀리거나, 누군가가 신고한다면 쉽게 스팸메일함에 들어가게 됩니다. .

    회신하다
    0
  • 迷茫

    迷茫2017-04-18 10:50:04

    우선 언어와는 관계가 없습니다.

    1. 이메일 주소와 헤더 정보를 선언합니다(msg.Headers.Add("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869"); Outlook 조끼 착용)

    3. 특별한 상황에서는 NetEase와 같은 법적 조치를 취한 후에도 일부 서버에서 귀하를 스팸으로 처리할 수 있습니다. 이는 귀하의 이메일 내용에 다음과 같은 이유로 인한 일부 민감한 단어나 불법적인 단어가 포함될 수 있기 때문입니다. 정보.

    회신하다
    0
  • 阿神

    阿神2017-04-18 10:50:04

    phpmailer를 보니 뭔가 설정했던 기억이 나네요. 일종의 SASL 인증 메커니즘인 것 같은데 그 외에는 아무것도 모르겠습니다

    회신하다
    0
  • 취소회신하다