Position: Home page » Blockchain » Springemail blockchain

Springemail blockchain

Publish: 2021-04-21 17:56:30
1. It is estimated that you did not import mail. Jar or JavaMail. Jar into your buildpath. See: http://stackoverflow.com/questions/6743031/how-to-resolve-javax-mail-messagingexception
2. It's the address of the SMTP server. Go to the corresponding email service provider's web page and find the content set by outlook, in which the address of the SMTP server is recorded

for example, using Gmail is smtp.gmail.com
3.

javax.mail:

package com.healist.email;

import javax.mail.*;< br />import javax.mail.internet.InternetAddress;< br />import javax.mail.internet.MimeMessage;< br />import java.util.Properties;< br />
/**
* Created by Healist on 2017/1/29.
*/
public class Email {
public static void main(String[] args) throws MessagingException {
//// 21019; Properties br />/SMTP21457;/ 36865;/ 24517;/ 39035;/36827;/ 36523;/ 202211;- 39564;- 35777< br />props.put(" mail.smtp.auth"& quot; true"< br />//27492;= 22788;- 22635;- 20889;- SMTP26381;- 21153;- 22120< br />props.put(" mail.smtp.host"& quot; smtp.qq.com"< br />//31471;- 21495QQQ31665;- 32473;- 20004;- 31471;- 202944;- 21478;- 19981;- 31649;- 587931649br />props.put(" mail.smtp.port"& quot; 587"< br />/27492;/ 22788;/ 22635;- 20889;- 20320;- 361344;-21495;
props.put(" mail.user"& quot; [email protected]" );< br />// QQQQQQ31665; 25480; 26435; 21435; 31665; 33258; 24049; 33719; 21462< br />props.put(" mail.password"& quot; dffajaehrb"< And then the second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second
String userName = props.getProperty(" mail.user"< br />String password = props.getProperty(" mail.password"< br />return new PasswordAuthentication(userName, password);< br />}
};< br />/Session mailSession = Session.getInstance(props, authenticator);< br />// 21019;/ br />MimeMessage message = new MimeMessage(mailSession);< br />// 32622;= 21457;< br />InternetAddress form = new InternetAddress(
props.getProperty(" mail.user");< br />message.setFrom(form);< br />
// 32622;- 25910;- 31665;
InternetAddress to = new InternetAddress(" [email protected]" );< br />message.setRecipient(MimeMessage.RecipientType.TO, to);< br />
// 32622;' 26631;' 39064;
message.setSubject(" < br />
// 32622;' message.setContent(" """ quot; text/html; charset=UTF-8"< br />
// 21457;- 36865;- br />Transport.send(message);< br />}
}

Spring Mail:

<? xml version=" 1.0" encoding=" UTF-8" gt;< br />< beans xmlns=" http://www.springframework.org/schema/beans" < br /> xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" < br /> xmlns:context=" http://www.springframework.org/schema/context" xmlns:tx=" http://www.springframework.org/schema/tx" < br /> xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"& gt;< br />
< context:component-scan base-package=" com.healist.*"& gt;< br /> < context:exclude-filter type=" annotation" expression=" org.springframework.stereotype.Controller" gt;< br /> < context:exclude-filter type=" annotation" expression=" org.springframework.web.bind.annotation.ControllerAdvice" /" gt;< br /> </ context:component-scan> < br />
<-- > >> br /> < bean id=" propertyConfigurer"< br /> class=" org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"& gt;< br /> < property name=" locations" gt;< br /> < list>< br /> < value> classpath:dev.properties</ value>< br /> <-- "229144;"26524;"26377;" 32622;"37324;" 32487;"32493;" 28155;" br /> </ list>< br /> </ property>< br /> </ bean>< br />
< bean id=" javaMailSender" class=" org.springframework.mail.javamail.JavaMailSenderImpl"& gt;< br /> < property name=" host" value=" mail.smtp.host}" gt;< br /> < property name=" port" value=" mail.smtp.port}" " gt;< br /> < property name=" username" value=" mail.smtp.username}" gt;< br /> < property name=" password" value=" mail.smtp.password}" " gt;< br /> < property name=" javaMailProperties"" gt;< br /> < props> br /> < prop key=" mail.smtp.timeout"& gt; mail.smtp.timeout}</ prop> br /> < prop key=" mail.smtp.auth" gt; mail.smtp.auth}</ prop> br /> < prop key=" mail.smtp.starttls.enable"& gt; mail.smtp.starttls.enable}</ prop> br /> < prop key=" mail.smtp.socketFactory.port"& gt; mail.smtp.port}</ prop> br /> < prop key=" mail.smtp.socketFactory.class"& gt; javax.net.ssl.SSLSocketFactory</ prop> br /> < prop key=" mail.smtp.socketFactory.fallback"& gt; false</ prop> br /> </ props> br /> </ property>< br /> </ bean>< br />
< tx:annotation-driven />< br />
</ beans> RRRRR}

4. "26469;" 30475;"30475;" 21457;"36865;" Email 21543; Jump 21457;"36865;" Email 24456;"31616;" 21333;"Jump MailSenderMessage23601;" xml version=" 1.0" encoding=" UTF-8" gt;< br /> <! DOCTYPE beans PUBLIC SPRING//DTD BEAN//EN" quot; spring-beans.dtd" gt;< br /> < beans>< br /> < bean id=" mailer" class=" org.springframework.mail.javamail.JavaMailSenderImpl"& gt;< br /> < property name=" host" gt;< br /> < value> smtp.163.com</ value>< br /> </ property>< br /> < property name=" javaMailProperties"" gt;< br /> < props> br /> <-- "229144;"26524;"25143;" 39564;"35777;" 27493;" br /> < prop key=" mail.smtp.auth" gt; true</ prop> br /> </ props> br /> </ property>< br /> < property name=" username" gt;< br /> < value> Email</ value>< br /> </ property>< br /> < property name=" password" gt;< br /> < value> Email</ value>< br /> </ property>< br /> </ bean>< br /> <-- > >< br /> < bean id=" mailMessage" class=" org.springframework.mail.SimpleMailMessage"& gt;< br /> < property name=" to" gt;< br /> < value> </ value>< br /> </ property>< br /> < property name=" from" gt;< br /> < value> </ value>< br /> </ property>< br /> < property name=" subject" gt; > It;-- Email -->< br /> < value> A Spring Mail sender</ value>< br /> </ property>< br /> </ bean>< br /> <-- >< br /> < bean id=" testMailSender" class=" test.mail.TestSenderMail"& gt;< br /> < property name=" mailMessage" gt;< br /> < ref bean=" mailMessage"/" gt;< br /> </ property>< br /> < property name=" mailer"& gt;< br /> < ref bean=" mailer"/" gt;< br /> </ property>< br /> </ bean>< br /> </ beans>< br /> 32622;' 23601;' 30452;' 25509;' 21457;' 36865;' 30475;' 30475;' TestSenderMail.java:
package test.mail;< br /> import org.springframework.mail.MailException;< br /> import org.springframework.mail.MailSender;< br /> import org.springframework.mail.SimpleMailMessage;< br /> public class TestSenderMail {
private MailSender mailSender;< br /> private SimpleMailMessage mailMessage;< br /> public TestSenderMail() {}
public SimpleMailMessage getMailMessage() {
return mailMessage;}< br /> public void setMailMessage(SimpleMailMessage mailMessage) {
this.mailMessage = mailMessage;}< br /> public MailSender getMailSender() {
return mailSender;}< br /> public void setMailSender(MailSender mailSender) {
this.mailSender = mailSender;}< br /> public void sendMail() {
SimpleMailMessage message = new SimpleMailMessage; // Email,
message.setText(" Email."< br /> try {
mailSender.send(message);< br />} catch (MailException e) {
System.out.println(" O "< br /> e.printStackTrace();< br />}
}
}
24456;- 31616;- 21333;- 21543s; TestApp.java
package test.mail;< br /> import org.springframework.context.ApplicationContext;< br /> import org.springframework.context.support.;< br /> public class TestApp {
public static void main(String[] args) {
ApplicationContext context = new (" test/mail/mail.xml"< br /> TestSenderMail sender = (TestSenderMail) context.getBean(" testMailSender"< br /> sender.sendMail();< br />}
//25243;- 22914;- 24322;- 29790;- 30417;- 25511;- 38382;- 39064,383838381;- 23601;- br /***DEBUG SMTP: QUIT failed with 250. MailSendException: Could not send mails: 354
* *com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.issueSendCommand). java:1388 *at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport. java:1215 (a) *com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport. java:586 "*/
}

2162121212162121212129616;" 23601;"21457;" 36865;"Email.
"37266;"3576024471;" 23558activation.jar mail.jar"2000444723548;" 210404040243rd;
5. Spring is an open source framework, which is created to solve the complexity of enterprise application development. One of the main advantages of the framework is its hierarchical architecture, which allows you to choose which component to use and provides an integrated framework for J2EE application development

in part 1 of this three part spring series, I'll introce the spring framework. I'll first describe the framework's functions from the perspective of the underlying model of the framework, and then I'll discuss two of the most interesting moles: Spring aspect oriented programming (AOP) and inversion of control (IOC) containers. Next, several examples will be used to demonstrate the application of IOC container in typical application use case scenarios. These examples will also form the basis for the expanded discussion later in this series. Later in this article, we will introce how the spring framework implements AOP construction through spring AOP

please refer to download, Download spring framework and Apache ant, which are needed to run the sample applications in this series

spring framework

spring framework is a layered architecture, which consists of seven well-defined moles. The spring mole is built on top of the core container, which defines how beans are created, configured, and managed, as shown in Figure 1

Figure 1. Seven moles of the spring framework
diagram of the spring framework

each mole (or component) that makes up the spring framework can exist alone or be implemented jointly with one or more other moles. The functions of each mole are as follows:

* core container: the core container provides the basic functions of spring framework. The main component of the core container is beanfactory, which is the implementation of factory pattern. Beanfactory uses the inversion of control (IOC) mode to separate the application configuration and dependency specifications from the actual application code
* spring context: Spring context is a configuration file that provides context information to the spring framework. The spring context includes enterprise services such as JNDI, EJB, e-mail, internationalization, verification and scheling functions
* spring AOP: through configuration management features, spring AOP mole directly integrates aspect oriented programming functions into spring framework. Therefore, it's easy to make any object managed by the spring framework support AOP. The spring AOP mole provides transaction management services for objects in spring based applications. By using spring AOP, declarative transaction management can be integrated into applications without relying on EJB components
* spring Dao: the JDBC Dao abstraction layer provides a meaningful exception hierarchy that can be used to manage exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reces the amount of exception code that needs to be written (such as opening and closing connections). JDBC oriented exceptions of spring Dao follow a common Dao exception hierarchy
* spring ORM: Spring Framework inserts several ORM frameworks to provide ORM object relation tools, including JDO, hibernate and ibatis SQL map. All of this follows spring's generic transaction and Dao exception hierarchy
* spring web mole: the Web context mole is built on top of the application context mole, providing context for web-based applications. Therefore, the spring framework supports integration with Jakarta struts. The web mole also simplifies the processing of multipart requests and binding request parameters to domain objects
* spring MVC framework: MVC framework is a full-featured MVC implementation for building web applications. Through the policy interface, MVC framework becomes highly configurable. MVC accommodates a large number of view technologies, including JSP, velocity, tiles, iText and poi

the functions of spring framework can be used in any J2EE server, and most of them are also suitable for unmanaged environments. The core point of spring is to support reusable business and data access objects that are not bound to specific J2EE services. There is no doubt that such objects can be reused between different J2EE environments (web or EJB), independent applications, and test environments

back to top

IOC and AOP

the basic concept of inversion of control mode (also known as dependency intervention) is: do not create objects, but describe how they are created. The code does not directly connect with objects and services, but describes which component needs which service in the configuration file. The container (in the spring framework, the IOC container) is responsible for linking these together

in a typical IOC scenario, the container creates all the objects and sets the necessary properties to connect them together to decide when to call the method. The following table lists one implementation mode of IOC
type 1 services need to implement special interfaces. Through the interfaces, these services are provided by objects, and dependencies can be queried from objects (for example, additional services needed)
type 2 services need to allocate dependencies through JavaBean attributes (for example, setter methods)
type 3 dependencies are provided in the form of constructors, The IOC container of

spring framework is not exposed in the form of JavaBean attributes, and is implemented by type 2 and type 3<

aspect oriented programming

aspect oriented programming, or AOP, is a programming technology that allows programmers to molarize behaviors (such as log and transaction management) that crosscut concerns or typical responsibility boundaries. The core construction of AOP is aspect, which encapsulates the behaviors that affect multiple classes into reusable moles

AOP and IOC are complementary technologies, both of which use molarization to solve complex problems in enterprise application development. In the typical object-oriented development mode, it may be necessary to put the logging statements in all methods and Java classes to realize the logging function. In AOP mode, log services can be molarized in turn and applied declaratively to components that need logs. Of course, the advantage is that Java classes don't need to know the existence of logging services, and they don't need to consider the relevant code. Therefore, the application code written in spring AOP is loosely coupled

the functions of AOP are fully integrated into the context of spring transaction management, logging and other features

back to top

IOC container

the core of spring design is org.springframework.beans package, which is designed to be used with JavaBean components. This package is usually not used directly by the user, but is used by the server as the underlying intermediary for most other functions. The next highest level abstraction is the beanfactory interface, which is an implementation of the factory design pattern, allowing objects to be created and retrieved by name. Beanfactory can also manage relationships between objects

beanfactory supports two object models

* the singleton model provides shared instances of objects with specific names, which can be retrieved ring query. Singleton is the default and most commonly used object model. Ideal for stateless service objects
* the prototype model ensures that a separate object is created for each retrieval. The prototype model works best when each user needs their own objects

the concept of bean factory is the foundation of spring as an IOC container. The IOC shifts the responsibility for doing things from the application code to the framework. As I will demonstrate in the next example, the spring framework uses JavaBean properties and configuration data to indicate the dependencies that must be set

beanfactory interface

because org.springframework.beans.factory.beanfactory is a simple interface, it can be implemented for various underlying storage methods. The most common definition of beanfactory is xmlbeanfactory, which loads the bean according to the definition in the XML file, as shown in Listing 1

Listing 1. Xmlbeanfactory

beanfactory = new xmlbeanfactory (New fileinputsteam & quot; mybean.xml"));

the bean defined in the XML file is loaded passively, which means that the bean itself will not be initialized before it is needed. To retrieve a bean from a beanfactory, simply call the getBean () method and pass in the name of the bean to be retrieved, as shown in Listing 2

Listing 2. GetBean ()

mybean mybean = (mybean) factory. GetBean (& quot; mybean");

the definition of each bean can be POJO (defined by class name and JavaBean initialization property) or factorybean. The factorybean interface adds an indirect level to applications built using the spring framework<

back to top

IOC example

the easiest way to understand inversion of control is to look at its practical application. In concluding part 1 of the three part spring series, I used an example to demonstrate how to inject (rather than build) the dependencies of an application through the spring IOC container

I use the use case of opening an online credit account as a starting point. For this implementation, opening a credit account requires users to interact with the following services:

* credit rating service to query the user's credit history information
* remote information link service, which inserts customer information and connects customer information with credit card and bank information for automatic debit (if necessary)
* the e-mail service sends e-mails to users about the status of credit cards

back to top

three interfaces

for this example, I assume that services already exist, and the ideal situation is to integrate them in a loosely coupled way. The following listing shows the application interfaces for the three services

Listing 3. Creditratinginterface

public interface creditratinginterface {
public Boolean (icustomer icustomer)< The credit rating interface shown in Listing 3 provides credit history information. It needs a customer object that contains customer information. The implementation of this interface is provided by the creditrating class

Listing 4. Creditlinkinginterface

public interface creditlinkinginterface {
public string geturl()< br /> public void setUrl(String url);< br /> public void linkCreditBankAccount() throws Exception ;
}

the credit link interface connects the credit history information with the bank information (if necessary), and inserts the user's credit card information. The credit link interface is a remote service, and its query is performed through the geturl () method. The URL is set by the bean configuration mechanism of the spring framework, which I'll discuss later. The implementation of this interface is provided by the creditlinking class

Listing 5. Email interface

public interface email interface {
public void sendemail (icustomer icustomer); and< br /> public String getFromEmail();< br /> public void setFromEmail(String fromEmail) ;< br /> public String getPassword();< br />
6. Let's take a look at sending email first. Sending email in spring is very simple. Just use spring's improved mailsender and mailmessage. The configuration code is as follows: smp.163.com true your email address, your email password, recipient address, your address a spring mail sender. After the configuration is finished, you can directly
7. In our life, there are all kinds of things (objects), there are airplanes, cars, ships, and I am a drop in the ocean
just ask: can a person who knows the underlying structure of an aircraft drive the aircraft well? Does a person who is proficient in the structure and underlying principles of a car guarantee that there will be no accidents when driving? Or on the other hand, an old taxi driver for many years is very skilled, but when you ask him about the architecture and underlying principles of the car, how many old drivers do you think can answer it accurately
that's right. We can't guarantee that a programmer who understands the underlying source code of spring will be a good programmer. A good programmer in my heart is a programmer who can put forward solutions. For example, Tsinghua University and Peking University are really just a process. The ultimate goal is to make contributions for the country and the people, which is our living value. So I'm not optimistic about reading spring source code. We are not the people who provide the bottom technology! Most programmers, I think the right way is to stand on the shoulders of giants and carry forward the essence left by the predecessors. In short, how to use it and why to use it so well is the key for most programmers to learn technology. It's like learning a driver's license. A coach only needs to care about whether you can drive or obey the traffic rules. He doesn't care whether you know how a car runs on the road
a person's energy and time are limited. In detail, a developer is a user of technology. The focus is on how to use it correctly and skillfully, rather than blindly caring about the underlying principles. If you want to fully understand the spring source code, first of all, you have to be very good at English. Secondly, how much time does it take? Even if you understand it, the harvest is not proportional to the effort. Why don't you spend a lot of time on more advanced and meaningful Java technologies? This is not to say that it is useless to read the spring source code, but to make our time more valuable, such as distributed micro services, blockchain technology, big data, python. As the IT leaders in the new era, should we meet the new future with the pace of the times? I advise most people not to look at the spring source code unless you are really interested in it as a technical research, which is OK. As a normal worker, it is not recommended to spend precious time to see it, let alone students. How to say that? In my opinion, students should attach great importance to their studies. They must be resolute and have a long way to go. First, they should expand the breadth of their knowledge and skillful use of technology. Second, they should cultivate their ability to solve problems independently and communicate and cooperate. Finally, they should consider the depth of technology
many years ago, I was interviewed with many questions, but never an interviewer would ask me the underlying source code of spring. Once, the architect of Alibaba interviewed me, until later, I became an interviewer. When I went to interview others, I would not ask spring source code, because 99.9% of enterprises recruited people to do the truth, Instead of asking you to study a technology, most of you care more about using the existing technology to complete some project functions. In addition to a few famous enterprises in the world, they need technical researchers to meet these requirements. It is estimated that they are at least graate students of famous universities to recruit such talents. Therefore, the most important thing for ordinary program developers is to learn how to use technology correctly and skillfully
we should not put the cart before the horse and aim too high. Since I was engaged in the Java instry, I really want to say that the person who is proficient in the whole stage and stack should belong to fengmaolingjiao. Therefore, we should let the knowledge we have learned plan strategies, draw inferences from one instance, and make thousands of miles of pure green. The above space is about some of my strong suggestions for reading spring source code. The final conclusion is that if you don't read or read it, you can leave it alone
do some interested people have to read

OK, in fact, it's not very difficult to read the spring source code
first of all, you should go to the official website spring.io to read and write the idea of spring framework, just like reading a book. To read the outline of this book, you should understand why you need to design the spring framework
then, you should read it in moles, starting from the core moles: for example,

IOC container, events, resources, I18N, validation, data binding, type conversion, spin, AOP.

then, if you are poor in English, you can use translation software to translate it into Chinese. After all, not every programmer is good at English, After all, it's easier for Chinese people to understand Chinese characters. Of course, some translations are not accurate. At this time, you can use the Internet to check the part you don't understand
then, download the spring jar package and open it with idea. You can use the download resource. You will find that there are detailed English comments on each method. While looking at the official instructions and the code writing, it's not difficult to find that a lot of code is very incisive, so it's a great test for a programmer's basic Java skills, especially reflection, JDK & # 92; Cglib agent, and Java common design patterns.
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750