J
Jan-Hendrik Lendholt
Hi everyone,
we wrote a simple cronjob for our server, which connects to a database,
gets some data eventually sends a mal via the java mail API.
Until now everything worked fine, but we since we updated our OS the
mail subject looks like:
=?ANSI_X3.4-1968?Q?Noch_freie_Plaetze_fuer:_=3FHSV-Hallencup_?=
=?ANSI_X3.4-1968?Q?2006=3F_am_8.1.2006_in_der?=
Uhm, I am really confused. The *really* strange thing is:
When I am executing the script via putty on the linux console, the
subject is being shown correctly - but running as cronjob the subject
is scrumbled ;-)
The following java code is used to create the message:
/*
* Created on 17.03.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
/**
* @author Mathias Deutz
*
*/
public class SendMail
{
public static void send(String recipient, String subject, String
message, String from)
{
try
{
Properties props = new Properties();
props.put("IP-ADDRESS", "IP-ADDRESS");
Session session = Session.getDefaultInstance( props );
Message msg = new MimeMessage( session );
InternetAddress addressFrom = new InternetAddress( from );
msg.setFrom( addressFrom );
InternetAddress addressTo = new InternetAddress( recipient );
msg.setRecipient( Message.RecipientType.TO, addressTo );
msg.setSubject( subject );
msg.setContent( message, "text/html" );
msg.saveChanges();
Transport.send( msg );
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
And the following code sends the message:
SendMail.send("(e-mail address removed)",betreff,nachricht,"(e-mail address removed)");
I hope I could make myself clear.
Thanks in advance!
Jan Lendholt
we wrote a simple cronjob for our server, which connects to a database,
gets some data eventually sends a mal via the java mail API.
Until now everything worked fine, but we since we updated our OS the
mail subject looks like:
=?ANSI_X3.4-1968?Q?Noch_freie_Plaetze_fuer:_=3FHSV-Hallencup_?=
=?ANSI_X3.4-1968?Q?2006=3F_am_8.1.2006_in_der?=
Uhm, I am really confused. The *really* strange thing is:
When I am executing the script via putty on the linux console, the
subject is being shown correctly - but running as cronjob the subject
is scrumbled ;-)
The following java code is used to create the message:
/*
* Created on 17.03.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
/**
* @author Mathias Deutz
*
*/
public class SendMail
{
public static void send(String recipient, String subject, String
message, String from)
{
try
{
Properties props = new Properties();
props.put("IP-ADDRESS", "IP-ADDRESS");
Session session = Session.getDefaultInstance( props );
Message msg = new MimeMessage( session );
InternetAddress addressFrom = new InternetAddress( from );
msg.setFrom( addressFrom );
InternetAddress addressTo = new InternetAddress( recipient );
msg.setRecipient( Message.RecipientType.TO, addressTo );
msg.setSubject( subject );
msg.setContent( message, "text/html" );
msg.saveChanges();
Transport.send( msg );
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
And the following code sends the message:
SendMail.send("(e-mail address removed)",betreff,nachricht,"(e-mail address removed)");
I hope I could make myself clear.
Thanks in advance!
Jan Lendholt