Java: Message Send failure summary (just outside the network server has a problem)

Source: Internet
Author: User
Tags ming email account mail account

Case one:

Operating Environment Comparison

1, the local use of the same code, system environment and e-mail account is no problem;

2, external network other server projects using the same technology is no problem;

problem Phenomenon

A link in the mail template (such as "http://www.baidu.com/...") is automatically executed after the mailbox is sent, causing other business errors.

processing Mode

1, before processing: "http://www.baidu.com/..." This part of the string is the entire text message template when the message is populated with a variable ;

2, after processing: "/http" fixed in the mail template, "www.baidu.com/..." This part will change and still use the program to populate the template;

Processing Results

The issue is resolved and the link in the message is no longer automatically executed.


Case TWO:

Operating Environment Comparison

1, the local use of the same code, system environment and email account is no problem;

problem Phenomenon

The following error message is sent:

com.sun.mail.smtp.smtpsendfailedexception:553 envolope sender mismatch with login user.

Processing mode

According to the information on the Internet search, the username and the sending address of the email are not matched, as follows:

: 553 envolope sender mismatch with login user.-->553 year Envolope sender does not match the logged-on user.
Session session = Session.getinstance (props, new Authenticator () {
protected Passwordauthentication getpasswordauthentication () {
String userName = "[email protected]";//a
return new passwordauthentication (userName, password);
Message msg = new MimeMessage (session);
Msg.setfrom (New internetaddress ("[email protected]");//B
       A: A and B must be unified!

So I examined it carefully and found that the usage of our project was a bit different, but it should be correct.

The B in our project is like this.

New InternetAddress (Stringutil.formataddress ("Xiao Ming", "[email protected]");/** * Format Name <[email protected]> address * @p    Aram Name * @param e-mail address * @return formatted address */public static string formataddress (string name, string email) {    if (stringhelper.isempty (name)) {return email; } try {//"%1 $ s <%2$s>" return String.Format ("%1 $ s <%2$s>", Mimeutility.encodetext (name, "Utf-8", "B"), email    );    } catch (Unsupportedencodingexception e) {e.printstacktrace (); }return email;}

By contrast:

A: "[email protected]"

B:?utf-8? b?5zkx572r5zwg5z+o?= <[email protected]>

So I'll change to the following:

New InternetAddress (Stringutil.formataddress ("[email protected]");//a and B.

Transmission network, restart the server, the test is really no problem, only the sender can not display the Chinese name "Xiao Ming" but the default "Ceshi".

One is that the sender is not good to see, the second is that I think it should not be the problem, because the local is the same configuration but no problem ah!

Feeling or the server itself, so I changed the code back, restart the server, and then test, hey ~~~~~~~~

The Pit ~ ~ E-mail was sent successfully. In other words, I just need to restart the server on the good!!!

But why? Ah ~ ~ This kind of thing is very difficult to explain, but often encounter!!

So long memory, next encounter local test machine no problem, but just outside the network server suddenly out of the question, and before the good; so brother Taiwan, this time regardless of 3,721, first restart the next try it! It's not a busy white.


Java: Message Send failure summary (just outside the network server has a problem)

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.