jspとjavamailを使用してhtml形式のメールを送信するためにjsp(spring、mvc model2)で作業していました。オブジェクトメッセージは電子メール受信者が読む部分です。私は基本的なhtmlタグを使ってデコレートしましたが、私はCSSを使用してより多くのデザインができるようにしたいと思います。 javamailを使用してメールを送信するときにCSSを使用する方法はありますか?jspを使用してhtml形式のメールを送信するときにCSSを使用
ここにメール送信者コントローラがあります。
@RequestMapping(value = "/mailSender", method = RequestMethod.GET)
public String mailSender(@RequestParam(value = "mem_id", defaultValue = "") String mem_id,
@RequestParam(value = "encrypt_no", defaultValue = "") String encrypt_no,
@RequestParam(value = "occu_code", defaultValue = "0") int occu_code) throws AddressException, MessagingException {
String host = "smtp.gmail.com";
final String username = "gmailid";
final String password = "gmailpw";
int port=465;
String recipient = mem_id;
String subject = "mail title";
Object message =
"<h2><strong>HOTEL NOMAD</strong></h2><br>"
+ "<h3>reset your pw<br><br>"
+ "http://127.0.0.1:8080/team/pwReset?encrypt_no="+encrypt_no+"&mem_id="+mem_id;
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.trust", host);
Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
String un=username;
String pw=password;
protected javax.mail.PasswordAuthentication getPasswordAuthentication() {
return new javax.mail.PasswordAuthentication(un, pw);
}
});
session.setDebug(true); //for debug
Message mimeMessage = new MimeMessage(session);
mimeMessage.setFrom(new InternetAddress("[email protected]"));
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
mimeMessage.setSubject(subject);
mimeMessage.setText((String) message);
mimeMessage.setContent(message, "text/html; charset=utf-8");
Transport.send(mimeMessage); }
System.out.println("an email has been sent");
if(occu_code!=0) return "redirect:/pay_after?occu_code="+occu_code+"&mem_id="+occupation.getMem_id();
return "redirect:/main";
}
エラー/ログを転記してください。 –
@ Al-KathiriKhalidエラー/ログはありません。javamailを使用してメールを送信するときにCSSを使用する方法があるかどうかを知りたいだけです。 – camila