| |

VerySource

 Forgot password?
 Register
Search
View: 1087|Reply: 2

Error in JavaMail. Compilation passed. When calling javax.mail.MessagingException: 502 Error: command not implemented.

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-9 21:40:01
| Show all posts |Read mode
DEBUG: setDebug: JavaMail version 1.3.1
DEBUG: getProvider () returning javax.mail.Provider [TRANSPORT, smtp, com.sun.mail.smtp.SMTPTransport, Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.163.com", port 25

220 163.com Anti-spam GT for Coremail System (163com [20050206])
DEBUG SMTP: connected to host "smtp.163.com", port: 25

EHLO nikodan
250-mail
250-PIPELINING
250-AUTH LOGIN PLAIN
250-AUTH = LOGIN PLAIN
250 8BITMIME
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN"
DEBUG SMTP: Found extension "AUTH = LOGIN", arg "PLAIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 dXNlcm5hbWU6
enh5b25nd2Vi
334 UGFzc3dvcmQ6
ODg4ODg4
550 users are locked
javax.mail.AuthenticationFailedException

-----------------------------------------
Source code:
 import javax.mail. *;
 import javax.mail.internet. *;
 import javax.activation. *;
-------------------------
public boolean sendEmail (String to, String subject, String content) {
String host = "smtp.163.com"; // mail.thinkrev.com
String user = "zxyongweb";
String password = "zxyongdb";
String from = "zxyongweb@163.com";
Ranch
Properties props = new Properties ();
props.put ("mail.smtp.host", host); // Specify the SMTP server
props.put ("mail.smtp.auth", "true"); // Specify whether SMTP authentication is required
try
{
Session mailSession = Session.getDefaultInstance (props);

mailSession.setDebug (true); // Whether debug information is displayed in the console

Message message = new MimeMessage (mailSession);
message.setFrom (new InternetAddress (from)); // From
message.addRecipient (Message.RecipientType.TO, new InternetAddress (to)); // Recipient

message.setSubject (subject); // Mail subject
message.setText (content); // Email content
message.saveChanges ();

Transport transport = mailSession.getTransport ("smtp");
transport.connect (host, user, password);
log.error ("Start sending:");
transport.sendMessage (message, message.getAllRecipients ());
transport.close ();
} catch (Exception e)
{
log.error ("Email failed:" + e);
System.out.println (e);
return false;
}
log.error ("Started successfully:");
return true;

}
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-11 09:18:01
| Show all posts
No one answered me
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-25 13:09:01
| Show all posts
<% @ page contentType = "text / html; charset = gb2312" language = "java" import = "java.sql. *, java.io. *, java.util. *"%>
<% @ include file = "include.inc"%>
<% @ page import = "com.bwrn.page.Show"%>
<% @ page import = "javax.mail.internet. *"%>
<% @ page import = "javax.activation. *"%>
<% @ page import = "javax.mail. *"%>
<%
request.setCharacterEncoding ("GB2312");
Show show = new Show ();
boolean blnError = true; // Retain exception information
boolean blnSend = false; // Reserved to send information
String strTo = "";
Class.forName (CLASSFORNAME);
Connection con = DriverManager.getConnection (SERVER, USER, PWD);
Statement stmt = con.createStatement ();
ResultSet rs = stmt.executeQuery ("select addrees from foremail where username = 'aa'");
if (rs.next ())
{
          strTo = rs.getString (1);
}

InternetAddress [] address = null;
String strMailserver = "smtp.163.com";
String [] arrstrFrom = request.getParameterValues ​​("addrres");
String strSubject = request.getParameter ("title");
String strMessage = request.getParameter ("content");
String file = request.getParameter ("file");
if (arrstrFrom.length> 0)
{
          int intI = 0;
          for (intI = 0; intI <arrstrFrom.length; intI ++)
          {
            if (! arrstrFrom [intI] .equals (""))
          {
          try
          {


            // Set the Mail server to be used and the transmission protocol used
            java.util.Properties props = System.getProperties ();
            props.put ("mail.host", strMailserver);
            props.put ("mail.transport.protocol", "smtp");
        props.put ("mail.smtp.auth", "true");

            // Generate a new Session service
            javax.mail.Session mailSession = javax.mail.Session.getDefaultInstance (props, null);

            mailSession.setDebug (true);

            Message msg = new MimeMessage (mailSession);
    // Set the sender of the email
            msg.setFrom (new InternetAddress (strTo));

            address = InternetAddress.parse (arrstrFrom [intI], false);
            msg.setRecipients (Message.RecipientType.TO, address);
            // Set the subject in the letter
            msg.setSubject (strSubject);
            // Set the delivery time
            msg.setSentDate (new java.util.Date ());
            // Set the MIME Type of the delivery
            msg.setText (strMessage);

            // Set the attachment in the letter;
            msg.setFileName ("file");
    // Send a letter
 Transport transport;
transport = mailSession.getTransport ("smtp");
    transport.connect ((String) props.get ("smtp.163.com"), username, password);

transport.sendMessage (msg, msg.getRecipients (Message.RecipientType.TO));

System.out.println ("abbcca");
            out.print ("The email has been succefully send to" + arrstrFrom [intI] + "<br/>");
            blnSend = true;
          }
          catch (Exception e)
          {
            if (blnError)
            out.print (show.errorBox (e.getMessage (), "Bad send email"));
            blnError = false;
            e.printStackTrace ();
          }
          }
        }
      }
else
{
          out.print (show.errorBox ("Please give more infomation", "wrong infomation"));
}

if (blnSend)
{
          out.print (show.errorBox ("Succefully", "Send Infomation"));
}
else if (blnError&! blnSend)
{
          out.print (show.errorBox ("Bad Send", "Send Infomation"));
}
%>
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list