Signing up to a mailing list

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Signing up to a mailing list

Todd_Power
What I want to do is create a form on my website that Nabble users and non-Nabble users can enter their email address into to subscribe to a mailing list. This is the code I have written so far:
<html>
<head>

<style type="text/css"> p {font-family:verdana;font-size:12px;} p2 {font-family:verdana;font-size:14px;font-weight:bold;} p3 {font-family:verdana;font-size:9px;} h1 {font-size:32px;color:#0a294f;font-variant:small-caps;text-align:center;} a{font-family:verdana;font-size:12px;color:#af2639;text-decoration:none;} a:hover{text-decoration:underline;} </style>
<script type="text/javascript"> function validate(nForm){ if (nForm['subscribers'].value == "") { alert('Please enter your email address'); return false; } alert('Thank you for subscribing'); return true; } </script>
</head>

<form method="post" target="_blank" action="http://n3.nabble.com/catalog/ManageSubscribers.jtp?forum=93800&tab=add" style="border: 3px solid rgb(207, 38, 45); padding: 2px 4px; width: 300px; background-color: rgb(240, 240, 240);" onsubmit="return validate(this)">
<input type="hidden" name="Action" value="Register" />

Mailing list

<p style="text-align:center;">Join the Rose Cottage mailing list</p>
<input type="hidden" name="action" value="save" />
<input type="hidden" name="forum" value="93800" />
<input name="subscribers" style="width:300px"></input>
<p style="text-align:center;">IMPORTANT<br/>Nabble will send an invitation to your email address<br />Please click the link to confirm your subscription<br /><br />
In the confirmation email, ensure you include the = sign in the link</p>
<div style="margin-top:1.4em;text-align:center;">
                <input type="submit" value="Subscribe"/>
        </div>
<br>
</form>
This works fine when I'm logged in as the owner of the mailing list. When I'm not logged in, I get told that I don't have authorisation to add users to the list. I understand that this is because the function on the website is designed for the admins and not for everyone else.

My question is, can I modify this form to allow users (Nabble and non-Nabble) to be able to add themselves to my mailing list?

Thanks,
Todd Power
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
I like your idea and initiative. I think the right solution is to create a REST interface that you can access behind the scenes. Otherwise any person would be able to invite users to your forum on your behalf (this isn't good, right?).

So, do you think a REST interface would be better in this case?
Or a simple form like that would be enough for you (and you also wouldn't care about people sending invites on your behalf)?

Here is one example of REST interface we have:
http://n2.nabble.com/API-for-Nabble-2-tp792099p1653228.html
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Todd_Power
Hi and thanks for your reply.

I'm unsure of what a REST interface is and how I would apply this to my code (I haven't been doing HTML very long, and I'm basically teaching myself).
Hugo wrote
http://n2.nabble.com/rest/PrivateAuthorization.jtp?forum=<id>&owner=<owner-email>&password=<owner-pwd>&action=<add-or-remove>&user=<user-email>
Applying this to me, can you confirm that the Id would be 15559, the owner is the email address I use to log in, and the action is "add"? I'm unclear on the password and user fields.
Hugo wrote
[The password] will be a special value that only Nabble knows how to generate. To know which value it is for you, check your "password" cookie value for the n2.nabble.com server. That value will be the password parameter and it is impossible to be guessed by other users.
What is the name of the cookie I'm looking for, or does this change for each user?

What would I need to enter for the user field, as this would change depending on what the user enters. I guess I would have to reference the subscribers field in the code, but I'm hoping you can tell me how to do this.
Hugo wrote
Or a simple form like that would be enough for you (and you also wouldn't care about people sending invites on your behalf)?
This wouldn't be a huge problem for me, although your idea does sound like the right solution.

Apologies for having so many questions.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
Todd_Power-2 wrote
I'm unsure of what a REST interface is and how I would apply this to my code (I haven't been doing HTML very long, and I'm basically teaching myself).
A REST interface is pretty much a link that you should call from your backend. When your code opens this link, Nabble changes your forum based on the parameters you provide. The idea is that your form will be submitted to your backend (e.g., java, php, whatever you have) and your code will build and open this link to notify Nabble about the changes.
Todd_Power-2 wrote
Applying this to me, can you confirm that the Id would be 15559, the owner is the email address I use to log in, and the action is "add"? I'm unclear on the password and user fields.
That REST interface is not what you want. That one is used to add members to the forum. This is different from adding subscribers. So we would have to build a similar interface for your case, which I think is worth doing.

So first please confirm that you would be able to change your backend to process this request and call the Nabble link. If you can't do this (e.g., your hosting service doesn't allow this), then we will have to go with the other solution.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Todd_Power
Hi Hugo,
Hugo wrote
So first please confirm that you would be able to change your backend to process this request and call the Nabble link. If you can't do this (e.g., your hosting service doesn't allow this), then we will have to go with the other solution.
Unfortunately, I don't think this will be possible. My website is hosted by Weebly and without purchasing my own domain, I have very limited access to the server.

What is the other solution?

Thanks for all your help.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
We have created a solution for you, but it will be available only after the next release (which should happen in the some days -- probably next Sunday). I will let you know when it is ready and how the form should look like.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
In reply to this post by Todd_Power
The solution is ready. Here is an example of how your form should look like:
<form method="post" action="http://n3.nabble.com/catalog/ManageSubscribers$Invite.jtp" style="border: 3px solid rgb(207, 38, 45); padding: 2px 4px; width: 300px; background-color: rgb(240, 240, 240);"> 
	<h1 style="font-size: 28px;">Mailing list</h1>
	<input type="hidden" name="app" value="93800" /> 
	<p style="text-align:center;font-weight:bold">Join my mailing list</p> 
	Your email: <input name="email" style="width:300px"></input> 
	<input type="submit" value="Subscribe Me"/>
		
	<p>
		<b>IMPORTANT</b><br/>
		Nabble will send an invitation to your email address.
		Please click the link to confirm your subscription.
	</p> 
</form>
Please try that and let me know if you need help.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Ana4
Hi Hugo,

I just tried this and got this:

Error 500

url=http://n3.nabble.com/catalog/ManageSubscribers$Invite.jtp?cid=1262340426465-665  user-agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729) referer=http://rosecottage.weebly.com/mail.html

RequestURI=/catalog/ManageSubscribers$Invite.jtp
Caused by:

fschmidt.util.servlet.JtpContextServlet$JtpServletException: url=http://n3.nabble.com/catalog/ManageSubscribers$Invite.jtp?cid=1262340426465-665  user-agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729) referer=http://rosecottage.weebly.com/mail.html
        at fschmidt.util.servlet.JtpContextServlet.handleException(JtpContextServlet.java:679)
        at fschmidt.util.servlet.JtpContextServlet.service2(JtpContextServlet.java:561)
        at fschmidt.util.servlet.JtpContextServlet.service(JtpContextServlet.java:326)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at org.mortbay.servlet.UserAgentFilter.doFilter(UserAgentFilter.java:81)
        at fschmidt.util.servlet.GzipFilter.doFilter(GzipFilter.java:137)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
        at cachingfilter.CachingFilter.doFilter(CachingFilter.java:120)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
        at fschmidt.util.servlet.BadBotFilter.doFilter(BadBotFilter.java:74)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:864)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: javax.servlet.ServletException: java.lang.NumberFormatException: null
        at nabble.view.lib.Jtp.parseLong(Jtp.java:729)
        at nabble.view.lib.Jtp.getLong(Jtp.java:719)
        at nabble.view.web.catalog.ManageSubscribers$Invite.service(ManageSubscribers.java:253)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at fschmidt.util.servlet.JtpContextServlet.service2(JtpContextServlet.java:557)
        ... 25 more
Caused by: java.lang.NumberFormatException: null
        at java.lang.Long.parseLong(Long.java:372)
        at java.lang.Long.parseLong(Long.java:461)
        at nabble.view.lib.Jtp.parseLong(Jtp.java:726)
        ... 29 more
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
Please post a link to the page where the form is. The error indicates that the form doesn't have a hidden field called "app" (which is the ID of your application in the Nabble database).
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Todd_Power
Hi Hugo,

http://rosecottage.weebly.com/contact.html

What's strange is that although I get the error message, the confirmation email still gets sent.

Thanks,
Todd
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
Thanks for reporting this, Todd. This bug will be fixed by the next release.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Todd_Power
Hi Hugo,

I've changed around a few things to include a onfocus/onblur and validation Javascript, and this is what I have at the moment.

<head>
<style type="text/css"> p {font-family:verdana;font-size:12px;} p2 {font-family:verdana;font-size:14px;font-weight:bold;} p3 {font-family:verdana;font-size:9px;} h1 {font-size:28px;color:#0a294f;font-variant:small-caps;text-align:center;} a{font-family:verdana;font-size:12px;color:#af2639;text-decoration:none;} a:hover{text-decoration:underline;} </style>
<script type="text/javascript"> <!-- function validate_email(field,alerttxt) { with (field) { apos=value.indexOf("@"); dotpos=value.lastIndexOf("."); if (apos<1||dotpos-apos<2) {alert(alerttxt);return false;} else {return true;} } } function validate_form(thisform) { with (thisform) { if (validate_email(email,"Please enter a valid e-mail address")==false) {email.focus();return false;} else { alert ("Nabble will send an invitation to your email address." + '\n' + "Please click the link to confirm your subscription.") } } } </script>
<script type="text/javascript"> <!-- function myFocus(element) { if (element.value == element.defaultValue) { element.value = ''; } } function myBlur(element) { if (element.value == '') { element.value = element.defaultValue; } } </script>
</head>

<form method="post" onsubmit="return validate_form(this)" action="http://n3.nabble.com/catalog/ManageSubscribers$Invite.jtp" style="border: 3px solid rgb(207, 38, 45); padding: 2px 4px; width: 300px; background-color: rgb(240, 240, 240);"> 
       

Mailing list

        <input name="app" value="93800" type="hidden"> 
        <p style="text-align: center; font-weight: bold;">Join the Rose Cottage mailing list</p> 
        <input onfocus="myFocus(this);" onblur="myBlur(this);" value="Please enter your email-address" name="email" style="width: 300px;"> 
        <div style="text-align:center;">
        <input type="submit" value="Subscribe"/>
        </div>
<br/>
</form>
At the moment they get sent to a Nabble page which says:
Success
An email has been sent to you to confirm the subscription.

Go back to Rose Cottage newsletter
This will confuse a lot of people on my website as the page they are being referred to will be blocked to them (i.e. they will get the Nabble message of Private Forum: Authorized Users Only) and will be scared off by it.

What I'd like to do is after clicking the OK button in the alert box, send them back to the homepage of my website (http://rosecottage.weebly.com). Is this possible?

Thanks,
Todd

PS: If this is too difficult, don't worry about it. Thanks for all the help you've given me so far.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
You are lucky because I was working on that code when I saw your message. So I added support for a "nextUrl" parameter that you can add to your form:
<input type="hidden" name="nextUrl" value="http://rosecottage.weebly.com" /> 
This will work only after the next release, but you can add the parameter now because it won't break anything. The next release should happen in a few days.
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Todd_Power
Thank you!!
Reply | Threaded
Open this post in threaded view
|

Re: Signing up to a mailing list

Hugo <Nabble>
Hi Todd, do you still use this subscription solution?
If yes, you will have to change some small details in the HTML form after the next Nabble release.
Please let me know so that I can provide more details to you.