Letter sent by javaMail



  • Please help with class management. javax.mail

    An annex to the Android that monitors the mailbox and sends answers. If I send a letter from one g-mailer to another g-mailer, it's OK. If there's a mailbox.

    Mistake:

    E/MailApp: Could not send email 501 5.5.4 Invalid argument
    

    Here's the code:

    public class Mail extends javax.mail.Authenticator {
    

    public boolean send() throws Exception {
    Properties props = _setProperties();

        Session session = Session.getDefaultInstance(props, this);
    
        MimeMessage msg = new MimeMessage(session);
    
        msg.setFrom(new InternetAddress(_from));
    
        InternetAddress[] addressTo = new InternetAddress[_to.length];
        for (int i = 0; i < _to.length; i++) {
            addressTo[i] = new InternetAddress(_to[i]);
        }
        msg.setRecipients(MimeMessage.RecipientType.TO, addressTo);
    
        msg.setSubject(_subject);
        msg.setSentDate(new Date());
    
        // setup message body
        BodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setText(_body);
        _multipart.addBodyPart(messageBodyPart);
    
        // Put parts in message
        msg.setContent(_multipart);
    
        // send email
        Log.d("Trying send", "host="+_host);
        Transport.send(msg);
    
        return true;        
    

    }

    @Override
    public PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(_user, _pass);
    }

    private Properties _setProperties() {
    Properties props = new Properties();
    props.put("mail.smtp.host", "smtp.mail.ru");
    props.put("mail.debug", "true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.user", "mymail@mail.ru");
    props.put("mail.smtp.port", 465);
    props.put("mail.smtp.socketFactory.port", 465);
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");

    return props;
    

    }

    }

    How do you even know what the server doesn't really like?

    Repeat, if I send a letter from the g-mailer, it's all right

    Here's the SMTP log:

    I/System.out: DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc.,1.4.1]
    I/System.out: DEBUG SMTP: useEhlo true, useAuth true
    I/System.out: DEBUG SMTP: useEhlo true, useAuth true
    I/System.out: DEBUG SMTP: trying to connect to host "smtp.mail.ru", port 465, isSSL false
    D/dalvikvm: GC_FOR_ALLOC freed 533K, 6% free 10131K/10696K, paused 22ms, total 24ms
    I/System.out: DEBUG SMTP: connected to host "smtp.mail.ru", port: 465
    E/MailApp: Could not send email 501 5.5.4 Invalid argument



  • smtp.mail.ru, port 465, isSSL false

    What if we try a sSSL = true or 25 port?




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2