SimpleMailMessage to and from issue
Hi,
Iīve got the following code up and running, see below:
My question is, I am receiving emails on my gmail account but the from is always myself and not the personīs email address, even if I hardcode it in the implementation class as message.setFrom("somebody@hotmail.com"); still does not work. Any ideas?
...
//implementation class:
@Service("mailService")
public class MailService {
@Autowired
private MailSender mailSender;
@Autowired
private SimpleMailMessage alertMailMessage;
public void sendMail(String from, String to, String subject, String body) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(body);
mailSender.send(message);
}
....
//servlet-...xml
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
<property name="host" value="smtp.gmail.com"/>
<property name="port" value="25"/>
<property name="username" value="xxx@gmail.com"/>
<property name="password" value="xxxx"/>
<property name="javaMailProperties">
<props>
<!-- Use SMTP transport protocol -->
<prop key="mail.transport.protocol">smtp</prop>
<!-- Use SMTP-AUTH to authenticate to SMTP server -->
<prop key="mail.smtp.auth">true</prop>
<!-- Use TLS to encrypt communication with SMTP server -->
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.debug">true</prop>
</props>
</property>
</bean>
SimpleMailMessage to and from issue
Hi,
Sorry about the code tags. Iīll put the next time.
So, If someone logs into my web application and sends me an email, there is no way of getting the from set to this personīs email address....this with GMAIL, but what about using yahoo, hotmail or even my with GoDaddy .
Is this the way SimpleMailMessage works?