The app uses 163 e-mail messages and is 163 thought to be junk mail pit Daddy experience! _ !

Source: Internet
Author: User

Recently there is a project, to send email to the user set up the mailbox alarm, and then used 163 mailbox, code is on-line borrowed ^ ^, as follows:

 PackageCom.smartdoorbell.util;ImportAndroid.os.AsyncTask;Importjava.util.Date;Importjava.util.List;Importjava.util.Properties;ImportJavax.activation.CommandMap;ImportJavax.activation.MailcapCommandMap;ImportJavax.mail.Authenticator;ImportJavax.mail.Message;ImportJavax.mail.Multipart;Importjavax.mail.PasswordAuthentication;Importjavax.mail.Session;ImportJavax.mail.Transport;Importjavax.mail.internet.InternetAddress;ImportJavax.mail.internet.MimeBodyPart;ImportJavax.mail.internet.MimeMessage;ImportJavax.mail.internet.MimeMultipart;/*** Created by Zhangjie on 15/8/31.*/ Public classJemailhelper {Private intPort = 25;//ports used by the SMTP protocol    PrivateString host = "smtp.163.com";//Sender mail Server    PrivateString user = "[email protected]";//User Account    PrivateString password = "xxxxxxx";//User Password    PrivateList<string>Emailtos; PrivateList<string>Emailccs; PrivateString subject; PrivateString body; PrivateList<string>paths; enumsendstatus {sending, UNDO, Sendok, sendfail}; PrivateSendstatus Sendstatus;  Public InterfaceJieemailinfterface {voidStartsend (); voidsendstatus (Sendstatus sendstatus); }    PrivateJieemailinfterface Jieemailinfterface;  Public voidsetjieemailinfterface (Jieemailinfterface jieemailinfterface) { This. Jieemailinfterface =Jieemailinfterface; }     PublicJemailhelper () {synchronized(Jemailhelper.class) {Sendstatus=Sendstatus.undo; }            }    //construct the server, port, account, password of the sending mail account     PublicJemailhelper (String host,intport, string user, string password) {        synchronized(Jemailhelper.class) {             This. Port =Port;  This. user =user;  This. Password =password;  This. Host =host; Sendstatus=Sendstatus.undo; }    }    /**     * @paramEmailtos * Main recipient's e-mail list *@paramEmailccs * CC person's e-mail list *@paramsubject * Mail title *@paramBody * Text content *@parampaths * Collection of attachment paths sent*/     Public voidSetParams (list<string> Emailtos, list<string>Emailccs, string subject, String body, List<String>paths) {         This. Emailtos =Emailtos;  This. Emailccs =Emailccs;  This. Subject =subject;  This. BODY =body;  This. paths =paths; }     Public voidSendEmail () {Newjieasyntask (). Execute (); }    Private voidSENDEMAILBG ()throwsException {Properties Properties=NewProperties (); Properties.put ("Mail.smtp.host", host); Properties.put ("Mail.smtp.port", Port); Properties.put ("Mail.smtp.auth", "true");//true must be quotedProperties.put ("Mail.transport.protocol", "SMTP"); Jieauthenticator Jieauth=Newjieauthenticator (user, password); Session Session=Session.getinstance (properties, Jieauth); //Create a messageMimeMessage msg =NewMimeMessage (session); //Set up senderMsg.setfrom (Newinternetaddress (user)); //Set Primary recipient        if(Emailtos! =NULL&&!Emailtos.isempty ()) {            intSize =emailtos.size (); Internetaddress[] Addresses=NewInternetaddress[size];  for(inti = 0; i < size; i++) {Addresses[i]=Newinternetaddress (Emailtos.get (i));        } msg.setrecipients (Message.RecipientType.TO, addresses); }        //set up e-mail for cc people        if(Emailccs! =NULL&&!Emailccs.isempty ()) {            intSize =emailccs.size (); Internetaddress[] Addresses=NewInternetaddress[size];  for(inti = 0; i < size; i++) {Addresses[i]=Newinternetaddress (Emailccs.get (i));        } msg.setrecipients (Message.RecipientType.CC, addresses);        } msg.setsubject (subject); //Create a message bodyMimeBodyPart Msgbodypart =NewMimeBodyPart ();        Msgbodypart.settext (body); //Create multipart to add additional partsMultipart MP =NewMimemultipart ();        Mp.addbodypart (Msgbodypart); //Creating file Attachments        if(paths!=NULL){             for(String path:paths) {if(path!=NULL) {MimeBodyPart Filebodypart=NewMimeBodyPart ();                    Filebodypart.attachfile (path);                Mp.addbodypart (Filebodypart); }            }                    }                //add multipart to the message bodyMsg.setcontent (MP); //Set DateMsg.setsentdate (NewDate ()); //Formatting AttachmentsMailcapcommandmap MC =(Mailcapcommandmap) commandmap. Getdefaultcommandmap (); Mc.addmailcap ("text/html;; X-java-content-handler=com.sun.mail.handlers.text_html "); Mc.addmailcap ("Text/xml;; X-java-content-handler=com.sun.mail.handlers.text_xml "); Mc.addmailcap ("Text/plain;; X-java-content-handler=com.sun.mail.handlers.text_plain "); Mc.addmailcap ("multipart/*;; X-java-content-handler=com.sun.mail.handlers.multipart_mixed "); Mc.addmailcap ("MESSAGE/RFC822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822 ");                            Commandmap.setdefaultcommandmap (MC);            Msg.savechanges (); //Send Messagetransport.send (msg); }    classJieauthenticatorextendsAuthenticator {PrivateString struser; PrivateString strpwd;  Publicjieauthenticator (string user, string password) { This. struser =user;  This. strpwd =password; }        protectedpasswordauthentication getpasswordauthentication () {return Newpasswordauthentication (struser, strpwd); }    }    classJieasyntaskextendsAsynctask<void, Void, sendstatus>{@Overrideprotected voidOnPreExecute () {Super. OnPreExecute (); if(Jieemailinfterface! =NULL) {jieemailinfterface.startsend (); }} @Overrideprotected voidOnPostExecute (sendstatus result) {Super. OnPostExecute (Result); if(Jieemailinfterface! =NULL) {jieemailinfterface.sendstatus (result); } sendstatus=Sendstatus.undo; } @Overrideprotectedsendstatus doinbackground (Void ... params) {Try{sendstatus=sendstatus.sending;                SENDEMAILBG (); Sendstatus=Sendstatus.sendok; } Catch(Exception e) {e.printstacktrace (); Sendstatus=Sendstatus.sendfail; }            returnSendstatus; }    }}


Then, you randomly enter a title and content test, no problem. So, put the alarm information, write the title and content, the cup has happened, has been unable to send a successful, return error message is as follows:

com.sun.mail.smtp.smtpsendfailedexception:554 DT:SPM 163 smtp11,d8cowacnisnyuenxzwhnbw--. 59036S2 1464056024,please See http://mail.163.com/help/help_spam_16.htm?ip=121.34.169.53&hostid=smtp11&time=1464056024

Go to http://mail.163.com/help/help_spam_16.htm?ip=121.34.169.53&hostid=smtp11&time=1464056024 This website a look, It was taken as junk mail! @ !

began to change the theme, change the content, changed n times, it is finally not considered to be spam, the pit father, the most gnawing father is, changed n all words after the ":" (Chinese Input method) replaced by ":" (English Input method), well, what is the rule?!!

PS: The above code needs to add Activation.jar, Additionnal.jar, Mail.jar, can be downloaded by Baidu itself.

The app uses 163 e-mail messages and is 163 thought to be junk mail pit Daddy experience! _ !

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.