gpt4 book ai didi

java - 在 jhipster 项目中正确配置我的 smtp 设置

转载 作者:行者123 更新时间:2023-11-30 10:52:14 24 4
gpt4 key购买 nike

我在配置我的 jhipster 应用程序时遇到了一些问题。这是我的配置文件的一部分:

mail:
host: smtp.mail.yahoo.com
port: 465
username: My_smtp_login
password: my_smtp_password
protocol: smtp
tls: true
auth: true
from: mymail@yahoo.pl
messages:
cache-seconds: 1
thymeleaf:
cache: false

和我的日志:

2015-12-22 20:47:09.680 DEBUG 13428 --- [hero-Executor-2] com.sun.mail.smtp                        : useEhlo true, useAuth false
2015-12-22 20:47:09.680 DEBUG 13428 --- [hero-Executor-2] com.sun.mail.smtp : trying to connect to host "smtp.mail.yahoo.com", port 465, isSSL false
2015-12-22 20:48:09.832 DEBUG 13428 --- [hero-Executor-2] com.sun.mail.smtp : EOF: [EOF]
2015-12-22 20:48:09.833 DEBUG 13428 --- [hero-Executor-2] com.sun.mail.smtp : could not connect to host "smtp.mail.yahoo.com", port: 465, response: -1
2015-12-22 20:48:09.834 WARN 13428 --- [hero-Executor-2] pl.mailinghero.service.MailService : E-mail could not be sent to user 'xxxx@yandex.com', exception is: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.mail.yahoo.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.mail.yahoo.com, port: 465, response: -1
2015-12-22 20:48:09.834 DEBUG 13428 --- [hero-Executor-2] p.mailinghero.aop.logging.LoggingAspect : Exit: pl.mailinghero.service.MailService.sendActivationEmail() with result = null

这不仅是yahoo 的问题,我用AOL、Gmail 和Yandex 检查过,但是smtp 也有同样的问题。 smtp配置的问题在哪里?

--编辑:

这是我的新 session :

spring:
profiles:
active: dev
devtools:
restart:
enabled: true
livereload:
enabled: false # we use Grunt + BrowserSync for livereload
datasource:
driver-class-name: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://localhost:3306/DemoApp?useUnicode=true&characterEncoding=utf8
name:
username: root
password: password123
jpa:
database-platform: org.hibernate.dialect.MySQLInnoDBDialect
database: MYSQL
show_sql: true
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
data:
elasticsearch:
cluster-name:
cluster-nodes:
properties:
path:
logs: target/elasticsearch/log
data: target/elasticsearch/data
mail:
host: smtp.mail.yahoo.com
port: 587
username: login@yahoo.com
password: password
protocol: smtp
tls: true
properties.mail.smtp:
auth: true
starttls.enable: true
ssl.trust: smtp.mail.yahoo.com
from: login@yahoo.com
messages:
cache-seconds: 1
thymeleaf:
cache: false

liquibase:
contexts: dev

server:
port: 8080

# ===================================================================
# JHipster specific properties
# ===================================================================

jhipster:
datasource: # JHipster-specific configuration, in addition to the standard spring.datasource properties
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
cache: # Hibernate 2nd level cache, used by CacheConfiguration
timeToLiveSeconds: 3600
ehcache:
maxBytesLocalHeap: 16M
mail: # specific JHipster mail property, for standard properties see MailProperties
from: DemoApp@localhost
metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
jmx.enabled: true
spark:
enabled: false
host: localhost
port: 9999
graphite:
enabled: false
host: localhost
port: 2003
prefix: DemoApp

但问题依然存在:

<html>
<head>
<title>DemoApp account activation</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p>Dear dkj</p>
<p>Your DemoApp account has been created, please click on the URL below to activate it:</p>
<p>
<a href="http://localhost:8080/#/activate?key=95189449636004891182">dkj</a>
</p>
<p>
<span>Regards,</span>
<br />
<em>DemoApp Team.</em>
</p>
</body>
</html>

2015-12-25 18:23:31.119 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : useEhlo true, useAuth false
2015-12-25 18:23:31.119 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : trying to connect to host "smtp.mail.yahoo.com", port 587, isSSL false
2015-12-25 18:23:31.581 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : connected to host "smtp.mail.yahoo.com", port: 587

2015-12-25 18:23:31.740 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "PIPELINING", arg ""
2015-12-25 18:23:31.740 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "SIZE", arg "41697280"
2015-12-25 18:23:31.740 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "8", arg "BITMIME"
2015-12-25 18:23:31.740 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "STARTTLS", arg ""
2015-12-25 18:23:32.436 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "PIPELINING", arg ""
2015-12-25 18:23:32.436 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "SIZE", arg "41697280"
2015-12-25 18:23:32.436 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "8", arg "BITMIME"
2015-12-25 18:23:32.436 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Found extension "AUTH", arg "PLAIN LOGIN XOAUTH2 XYMCOOKIE"
2015-12-25 18:23:32.436 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM
2015-12-25 18:23:33.470 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : use8bit false
2015-12-25 18:23:33.703 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : got response code 501, with response: 501 Syntax error in arguments

2015-12-25 18:23:33.945 DEBUG 5677 --- [-app-Executor-1] com.sun.mail.smtp : MessagingException while sending

com.sun.mail.smtp.SMTPSendFailedException: 501 Syntax error in arguments

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2203) ~[javax.mail-1.5.4.jar:1.5.4]
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1694) ~[javax.mail-1.5.4.jar:1.5.4]
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1194) ~[javax.mail-1.5.4.jar:1.5.4]
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:448) [spring-context-support-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:345) [spring-context-support-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340) [spring-context-support-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at net.demo.service.MailService.sendEmail(MailService.java:65) [classes/:na]
at net.demo.service.MailService.sendActivationEmail(MailService.java:81) [classes/:na]
at net.demo.service.MailService$$FastClassBySpringCGLIB$$bf501f3f.invoke(<generated>) [classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:718) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at net.demo.aop.logging.LoggingAspect.logAround(LoggingAspect.java:51) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:58) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:108) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65]
Caused by: com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in arguments

at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1703) ~[javax.mail-1.5.4.jar:1.5.4]
... 29 common frames omitted

2015-12-25 18:23:34.189 WARN 5677 --- [-app-Executor-1] net.demo.service.MailService : E-mail could not be sent to user 'login@gmail.com', exception is: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 501 Syntax error in arguments
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in arguments

2015-12-25 18:23:34.189 DEBUG 5677 --- [-app-Executor-1] net.demo.aop.logging.LoggingAspect : Exit: net.demo.service.MailService.sendActivationEmail() with result = null

我找到了信息,删除了

from: mymail@yahoo.pl should help, but it didn't work in my case

最佳答案

我和你一样的错误。我的解决方案是将 from: mymail@yahoo.pl (必须与 yahoo 邮件用户名相同)放到以下部分:

jhipster:
邮件:
来自:mymail@yahoo.pl

也可以在 application-prod.yml 或 application-dev.yml 文件中找到,但在以下几行:

spring:
mail:

部分。所以我的整个解决方案如下所示(使用您的示例凭据):

spring:
...
mail:
host: smtp.mail.yahoo.com
port: 587
username: mymail@yahoo.pl
password: my_smtp_password
protocol: smtp
tls: true
properties.mail.smtp:
auth: true
starttls.enable: true
ssl.trust: smtp.mail.yahoo.com

和:

jhipster:
...
mail:
from: mymail@yahoo.pl

关于java - 在 jhipster 项目中正确配置我的 smtp 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34423868/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com