vaio
vaio

Reputation: 101

Sending e-mails with Spring Email

I'm trying to send an e-mail with Spring Email.

My bean:

@Bean
public JavaMailSender getJavaMailSender() {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost(„???“);
    mailSender.setPort(587);

    mailSender.setUsername(„???“);
    mailSender.setPassword(„???“);

    Properties props = mailSender.getJavaMailProperties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.debug", "true");

    return mailSender;
}

Send function:

public void sendSimpleMessage(String to, String subject, String text) {

    SimpleMailMessage message = new SimpleMailMessage(); 
    message.setTo(to); 
    message.setSubject(subject); 
    message.setText(text);
    emailSender.send(message);
}

I'm receiving a positive response, but the e-mail is not delivered.

250 OK id=1dHroI-0002US-95
DEBUG SMTP: message successfully delivered to mail server
QUIT
221 smtprelay07.ispgateway.de closing connection

Can anyone please tell what could be wrong? Thank you.

Upvotes: 1

Views: 624

Answers (1)

vaio
vaio

Reputation: 101

message.setFrom(...) solved the problem!

Upvotes: 1

Related Questions