Created
October 28, 2018 10:43
-
-
Save technikamateur/43f23d89ad0080a3a46a9b9daf24d2b1 to your computer and use it in GitHub Desktop.
Sending E-Mail with Java Salepoint (wrong way)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package videoshop.customer; | |
import org.springframework.mail.MailException; | |
import org.springframework.mail.SimpleMailMessage; | |
import org.springframework.mail.javamail.JavaMailSenderImpl; | |
public class CustomerMail { | |
private String mailText; | |
private String reciever; | |
private SimpleMailMessage msg; | |
private JavaMailSenderImpl mailSender; | |
CustomerMail() { | |
mailText = "Vielen Dank für ihre Registrierung. Se schuldne uns seear fiel gelt!"; | |
mailSender = new JavaMailSenderImpl(); | |
mailSender.setHost("smtp.mailtrap.io"); | |
mailSender.setPort(2525); | |
mailSender.setUsername("0c84e9b0d90249"); | |
mailSender.setPassword("424f47843a6368"); | |
} | |
public void setReciever(String reciever) { | |
this.reciever = reciever; | |
} | |
public void sendMsg() { | |
msg = new SimpleMailMessage(); | |
msg.setTo(reciever); | |
msg.setText(mailText); | |
msg.setSubject("Drei Chinesen"); | |
try { | |
this.mailSender.send(msg); | |
} | |
catch (MailException ex) { | |
// simply log it and go on... | |
System.err.println(ex.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment