用Java写发送邮件的程序,经常被当做垃圾邮件处理怎么解决
PHPz
PHPz 2017-04-18 10:48:04
0
3
659
 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 "发送成功!";
}
PHPz
PHPz

学习是最好的投资!

reply all(3)
Ty80

....No matter what language you write in, if the legality and authority of your email address are not recognized, if your content is slightly wrong, or if someone reports you, it will easily end up in the spam mailbox.

迷茫

First of all, it has nothing to do with language.

1.. Declare the email address and header information (msg.Headers.Add("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869"); put on the Outlook vest)

3. In special circumstances, some servers may still treat you as a spam mailbox after you have put on a legal vest, such as NetEase. This is because your email content may contain some sensitive words or illegal information. of.

阿神

Looking at phpmailer, I remember to set something up, it seems to be some kind of SASL authentication mechanism, but I don’t know anything else

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!