Here is my code for sending email:
public void sendMail()
{
try
{
// Propiedades de la conexión
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session mailSession = Session.getDefaultInstance(props, auth);
Transport transport = mailSession.getTransport();
MimeMessage message = new MimeMessage(mailSession);
Multipart multipart = new MimeMultipart("alternative");
BodyPart text = new MimeBodyPart();
text.setContent(mailMessage,"text/html; charset=UTF-8");
multipart.addBodyPart(text);
message.setContent(multipart);
if(friendlyName != null){
//String send = friendlyName + " <" + sender + ">";
message.setFrom(new InternetAddress(sender, friendlyName));
}else{
message.setFrom(new InternetAddress(sender));
}
message.setSubject(subject,"UTF-8");
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(receiver));
transport.connect();
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
transport.close();
}catch (Exception e) {
// TODO: handle exception
}
}
When I send an email I get this output on console (or catalina.out):
>>>>>Sending data EHLO xxxxxx<<<<<<
>>>>>Sending data AUTH LOGIN<<<<<<
>>>>>Sending data xxxxxxxxxxxxxxxxxxxx<<<<<<
>>>>>Sending data xxxxxxxxxxxxxx<<<<<<
>>>>>Sending data MAIL FROM: <<<<<<
>>>>>Sending data RCPT TO: <<<<<<
>>>>>Sending data DATA<<<<<<
>>>>>Sending data <<<<<<
>>>>>Sending data .<<<<<<
>>>>>Sending data QUIT<<<<<<
How can I disable this output? My catalina.out is growing too fast. Setdebug(false) method does not solve my problem.
In spring this worked for me:
<property name="javaMailProperties">
<props>
<prop key="mail.transport.protocol">smtp</prop>
<prop key="mail.smtp.auth">false</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.debug">false</prop>
</props>
</property>
tested with versions 1.4.7+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With