Note that there are some explanatory texts on larger screens.

plurals
  1. POLog4j exception when sending mail with simple-java-mail
    primarykey
    data
    text
    <p>I already read this tutorial on the <a href="http://www.simplejavamail.org/#features" rel="nofollow noreferrer">Simple Java Mail</a> wiki and I have downloaded all required libraries (Log4j, JavaMail API, Activation framework) although when I try running my program I get this error:</p> <blockquote> <p>log4j:WARN No appenders could be found for logger (org.codemonkey.vesijama.Mailer). org.codemonkey.vesijama.MailException: Generic error: Exception reading response log4j:WARN Please initialize the log4j system properly.</p> </blockquote> <p>This is the source code i use:</p> <pre><code>import javax.mail.Message.RecipientType; import org.codemonkey.vesijama.Email; import org.codemonkey.vesijama.MailException; import org.codemonkey.vesijama.Mailer; import org.apache.log4j.*; public class testSend { final Email email = new Email(); static Logger log = Logger.getLogger(mailmailan.class); public testSend{ try{ BasicConfigurator.configure(); email.setFromAddress("test", "XXXXX@gmail.com"); email.setSubject("hey"); email.addRecipient("hai", "XXXXXXX@yahoo.com", RecipientType.TO); email.setText("We should meet up!"); email.setTextHTML("&lt;b&gt;We should meet up!&lt;/b&gt;"); email.addAttachment("output.xls", odfDatasource); new Mailer("smtp.gmail.com", 465, "XXXXXXXX@gmail.com", "XXXXXX").sendMail(email); } catch(MailException me) { System.out.println(me); } } } </code></pre> <p>I also tried using port 587 although I got the same error.</p> <p><strong>Side question:</strong> It also says it is possible to add attachments. Does anyone have a code example of how I can attach a <code>.xls</code> file.</p> <p><strong>Edit:</strong> I have success sent mail (Added log4j.xml to every folder), but i still failed to use <code>addAttachment</code>. I have also updated my source code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload