• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Some notes and examples on setting up the transactional email

 
Ranch Hand
Posts: 41
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're ok, you're ok. Otherwise,

Email errors
Many are possible e.g.

Exception in thread "pool-1-thread-3" net.jforum.exceptions.MailException: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. ll10sm31874440wic.9 - gsmtp

Unless you know what these mean, and quickly, I suggest you ignore them and concentrate on accurate configuration (I don't know everything about Java Mail anyhow).


First Step
If this is your error,

Error while sending the email:
net.jforum.exceptions.MailException: javax.mail.AuthenticationFailedException: xx.xx.xx <...


Then .jar removal may be the change needed. If present, remove this .jar from the webApp,

webContent/libs/activation.jar

The following post names Jetty. I gathered this .jar in an Eclipse Dynamic Web project also, so I assume this is a likely problem in many setups,
https://coderanch.com/t/608872/jforum/Jetty-email-sending#2780317

Steps
What we will be doing
Informing Java Mail how to send messages from JForum. Private messages are not covered here.

To send mail, Java Mail needs to be configured with details about an SMTP server. Most normal email accounts (with an ISP, a firm, an independent provider, Yahoo, etc.) will have a SMTP server. Even now, some email providers may be difficult about giving up the data. Try a web-search.

In the simple setup talked about here, no email will be sent to the SMTP account. JForum uses the server to distribute across the web (initially, to whatever address is in the test button).

Email troubleshooting is easier if you have two or three email addresses to play with ( one to configure in, and at least one for testing).

Where to configure
There are two places,

appBase > WEB-INF > config > SystemGlobals.properties

and the web-based admin panel.

I have no idea about the interaction between the two. They duplicate settings, with the text config file having more control. If they behave like the rest of JForum, the panel will be a simple override of the settings. What I did find was that clearing the boxes on the admin panel results in a setup that does nothing, so presumably it reflects the configuration of the properties.

How to test - the test button
If you logon to admin panel, there is a "Send a Test Email" button.

Initially I ignored this. With a stream of errors and exceptions, I needed registration to work. But.. read on. And... use the test button.

The test button takes an email address (this had me fooled, I thought it took a body, which action throws an error).


SSL, or not
Secure Socket Layer. Means emails are encrypted.

As a newcomer I thought emails probably should be encrypted. After all, they have passwords. How big a risk having emails sniffed is for real, I don't know. Maybe we do the web a favour by not cascading information bleed? What I can say is that external host providers don't always see it that way. It's only a call and response to verify a reality. Either the other end is encrypted or not. So, the choice is likely determined by the final hosting environment of the forum. If you are using an external host, you should check with your provider, see what they provide. While asking, ask them about their provision for mail transports (MTA) and so forth - if they have none, then the JForum -> Java Mail feature will not work anyhow (Java Mail uses the local mail transport).

Use of a SMTP provider
Some email banlists will ban an webApp automatically if they discover automated, or suspected automated email was sourced from moving, or otherwise unverified, IP addresses. This is almost bound to happen if the webApp is hosted on someone else's server.

One way round this is not to use any old SMTP server, but an external service. These SMPT services use addresses unlikely to be banned, with issues rapidly adressed if they are. In return they expect good behaviour. Try

  • <a href="https://uk.mailjet.com/pricing">Mailjet<a>
  • <a href="http://mandrill.com/pricing/">Mandrill<a>
  • <a href="http://sendgrid.com/pricing.html">Sendgrid<a>



  • Example Configurations for SystemGlobals.properties

    GMail SSL
    First, GMail can be configured for two-step authentication. If this is the situation, the protection layer must be enabled to allow access from the working JForum app.

    After that,
    mail.sender = someName@gmail.com
    mail.smtp.auth = true
    mail.smtp.host = smtp.gmail.com
    # Non-SSL default port is 25. If SSL, the default port is 465.
    mail.smtp.port = 465
    mail.smtp.username = someName@gmail.com
    mail.smtp.password = someSmtpPassword
    # the period in milliseconds JForum waits before sending next mail to SMTP server.
    # Some SMTP server will response 421 if you send a lot of mails in a very short time.
    # set it to 0 (zero) to disable it completely
    mail.smtp.delay = 2000

    # SSL support for SMTP. Set it to "true" if your
    # host requires that (GMail does). Don't forget
    # to change the mail.smtp.port too
    mail.smtp.ssl = true

    # If set to true, the POP3 TOP command will not be used to fetch message headers.
    # This is useful for POP3 servers that don't properly implement the TOP command,
    # or that provide incorrect information in the TOP command results.
    mail.pop3.disabletop = true

    # If the mail.smtp.host cannot be resolved, JavaMail sends a HELO
    # without a hostname - which is a violation of the SMTP protocol
    # You can set this property to force the hostname
    mail.smtp.localhost =


    Other SSL
    mail.sender = someEmailAddress
    mail.smtp.auth = true
    mail.smtp.host = someServerName (e.g. smtp.coolpost.fr)
    # Non-SSL default port is 25. If SSL, the default port is 465.
    mail.smtp.port = 465
    mail.smtp.username = (e.g. more than likely, an email address)
    mail.smtp.password = (e.g. more than likely, the passwordd usually used for an email account)
    # the period in milliseconds JForum waits before sending next mail to SMTP server.
    # Some SMTP server will response 421 if you send a lot of mails in a very short time.
    # set it to 0 (zero) to disable it completely
    mail.smtp.delay = 2000

    # SSL support for SMTP. Set it to "true" if your
    # host requires that (GMail does). Don't forget
    # to change the mail.smtp.port too
    mail.smtp.ssl = true

    # If set to true, the POP3 TOP command will not be used to fetch message headers.
    # This is useful for POP3 servers that don't properly implement the TOP command,
    # or that provide incorrect information in the TOP command results.
    mail.pop3.disabletop = true

    # If the mail.smtp.host cannot be resolved, JavaMail sends a HELO
    # without a hostname - which is a violation of the SMTP protocol
    # You can set this property to force the hostname
    mail.smtp.localhost =


    Non SSL
    mail.sender = someEmailAddress
    mail.smtp.auth = true
    mail.smtp.host = someServerName (e.g. smtp.coolpost.fr)
    # Non-SSL default port is 25. If SSL, the default port is 465.
    mail.smtp.port = 25
    mail.smtp.username = (e.g. more than likely, an email address)
    mail.smtp.password = (e.g. more than likely, the passwordd usually used for an email account)
    # the period in milliseconds JForum waits before sending next mail to SMTP server.
    # Some SMTP server will response 421 if you send a lot of mails in a very short time.
    # set it to 0 (zero) to disable it completely
    mail.smtp.delay = 2000

    # SSL support for SMTP. Set it to "true" if your
    # host requires that (GMail does). Don't forget
    # to change the mail.smtp.port too
    mail.smtp.ssl = false

    # If set to true, the POP3 TOP command will not be used to fetch message headers.
    # This is useful for POP3 servers that don't properly implement the TOP command,
    # or that provide incorrect information in the TOP command results.
    mail.pop3.disabletop = true

    # If the mail.smtp.host cannot be resolved, JavaMail sends a HELO
    # without a hostname - which is a violation of the SMTP protocol
    # You can set this property to force the hostname
    mail.smtp.localhost =


    I don't know the circumstances for needing the mail.smtp.localhost option, but duplicating in the value of mail.smtp.host may be of use.

    Needing a true value for authentication is common now.


    Simple Testing
    Logon as admin, go to the admin panel, find the email test button. Type in an email address, preferably one somewhere else to the email account configured for serving. Press 'send'.

    Hopefully you won't get an error, but a popup saying the email was sent successfully. Bear in mind sucessful sending is not sucessful recieving. If there are problems, double check you are using a working Mail Transport, and check the 'Junk'/'Trash' bins in the targeted account.


    Complex testing
    Testing JForum registration, likely. It may be a useful to enable/disable,

    mail.notify.answers

    ...depending on your needs.


    Snags
    Jforum doesn't forget users, or allow duplicate user email addresses. Probably good security. If users wish to re-register, this (incidental to this thread, but anyhow) likely means database editing will be needed.

    Anyhow, a third email address will be helpful. Otherwise, access to the database is needed to edit out new users when they are tried.

    Testing will be easier and more comprehensive online ...if getting online is feasible. JForum registration does allow for manual "goto page and enter supplied details" registration, so that may be possible on a local development setup.

    Refs
    Uncomplex Gmail settings,
    http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm

    If you run into trouble, try this,
    https://dunithd.wordpress.com/2009/10/22/send-email-using-javamail-api-and-your-gmail-account/

    Takes a domain name and returns information about CNAMES, banlists, original hosts and more,
    http://mxtoolbox.com/
     
    You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic