gpt4 book ai didi

JavaMailSenderImpl 配置一个电子邮件地址并使用另一个电子邮件地址作为 MimeMessageHelper.setFrom 但表示权限问题

转载 作者:行者123 更新时间:2023-12-02 04:33:40 25 4
gpt4 key购买 nike

我已经配置了我的电子邮件属性,但从地址发送电子邮件时正在动态更改

我尝试使用与发件人地址相同的电子邮件地址,然后它可以工作,但如果我使用不同的电子邮件地址,则会出现权限问题。

电子邮件配置是:

<bean id = "mailSender"class="org.springframework.mail.javamail.JavaMailSenderImpl"><
property name = "host"value="mail.******.com"/><
property name="port"value="587"/><
property name="username"value="support@*****.com"/><
property name="password"value="******"/><
property name="javaMailProperties">
<props><
prop key="mail.transport.protocol">smtp</prop><
prop key="mail.debug">true</prop>
</props>
</property>
</bean>
public void sendBulkEmail(String[] to, NewCampaignDTO campaign, String mailTemplate) throws MailException {
if (isMailsBlocaked()) {
to = new String[0];
}
MimeMessagePreparator preparator = imsGeneralUtils.prepareBulkEmailMessage(to, campaign, mailTemplate);
// Send Message
javaMailSender.send(preparator);

}
public MimeMessagePreparator prepareBulkEmailMessage(String[] to, Object campaign, String mailTemplate) {
return new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws Exception {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, CharEncoding.UTF_8);
message.setBcc(AddToStringArray(to, DEFAULT_MAIL_TO_ALL));
message.setSubject(campaign.getSubject());
message.setFrom(campaign.getFromEmail(), campaign.getFromName());
message.setReplyTo(campaign.getReplyToEmail());
Map<String, Object> model = new HashMap<>();
model.put("objInfo", campaign.getEmailBody());
model.put("url", getSettingValue(Settings.FRONT_END_APP_URL));
String body = FreeMarkerTemplateUtils
.processTemplateIntoString(freeMakerConfig.getTemplate(mailTemplate), model);
message.setText(body, true);
}
};
}

失败的邮件:com.sun.mail.smtp.SMTPSendFailedException:550 5.7.1 客户端无权作为此发件人发送

最佳答案

您需要为该电子邮件启用 SMTP。如果问题仍然存在,请启用调试并查看。谢谢

关于JavaMailSenderImpl 配置一个电子邮件地址并使用另一个电子邮件地址作为 MimeMessageHelper.setFrom 但表示权限问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56562087/

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