Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Contact Form - From Address Help

Go to End

15 Posts   3772 Views


Community Member, 470 Posts

31 July 2008 at 12:38pm

Hmm Okay I have a test copy of trunk on a server to play around with.

I took the code we've been using here, the one I put up on and installed it fresh on there...Still nothing. The exact same problem.

I'm not really sure why it works for you, and not me. This is very odd...


Community Member, 470 Posts

1 August 2008 at 5:28am

Okay more updates.

It seems the forms in general don't submit. Testing around on my svn copy of trunk, I changed the contact page to a basic user defined form to test. The submission goes through and is submitted to the database and is shown under the page's 'submissions' tab, but it never emails. So it seems to be something with the forms in general, however I have a newsletter setup and that works.

Now the custom form you helped me with here is installed on 2.2.2 stable, but I think the problem is for both the svn and stable.

However, on the same server I have a client site running rc3, and a simple user defined form still works. So it seems the problem is with forms not sending on 2.2.2 or later (trunk), but newsletters do send...odd.

Any idea how to debug this? This is kind of a show stopper if I'm building sites and can't send form emails. I have my own server, so all client sites will be on the same one. Not sure if it's a server configuration or a problem with 2.2.2. I have set the Email::setAdminEmail() in the config file.


Community Member, 470 Posts

1 August 2008 at 5:02pm

Edited: 01/08/2008 5:38pm

And more updates!

Okay the user defined forms do work. There was a mix up of SPF records and some other things, along with the email I was sending them to, so ignore the stuff above.

I've made some progress with with the custom contact form.

The reason it wasn't sending, was that I had commented out the $dataFieldByName(SecurityID) in the template. As far as I had read, I didn't think it was available in 2.2.2, only trunk which I'm not using for this live site. I've since included it and it works fine, but emails are bouncing. The form sends from a users end point of view, but I get a bounced email saying there was no recipient addresses, so the email obviously couldn't be sent.

It seems the info in the doForm() function aren't being sent. The "To" and "Subject" field are blank, and the "From" address defaults to the admin email set in my config file, not the different one that is in the doForm() function.

This is what I gathered from the bounced email that gets sent back to the default address in the config file.


Forum Moderator, 922 Posts

4 August 2008 at 7:28pm

Not sure why the parameters aren't working properly - could be because it's the Email_Template class instead, but anyways, here's some code which you can replace your doForm() method with:

Maybe this will work!


Community Member, 470 Posts

14 August 2008 at 5:59am

Just wanted to update and let you know, the new code does work so everything is running perfectly.

Only got around to doing it today, as I had to work on other projects.


Forum Moderator, 922 Posts

14 August 2008 at 9:28am

Great to hear!

Were you successful using the FormData template control for the email?



Community Member, 470 Posts

14 August 2008 at 1:11pm

Edited: 14/08/2008 1:13pm

Yup, I had no problem accessing the FormData to be used in the template.

I have another quick question, a bit off topic. Not to do with this problem, but I'm working on another form.

I wrote a newsletter sign up form, and upon sign up, the system sends the default newsletter to the user. There is basically only one newsletter for now, so it's easier just to send it to them auto and store their email for later use.

How do I access the $UnsubscribeLink variable in the template so I can include this link in the first email that gets sent, after they sign up?

Here is the signup function

    function M3SignUp($data, $form) {
        $member = new Member();
        if($group = DataObject::get_one('Group', "Code = 'm3-rental-strategy'")) {
	$email = new Email_Template();
	$email->ss_template = 'SignUp_Email';
      	$email->from = 'removed';
      	$email->to = $data['Email'];
      	$email->subject = 'Default Newsletter';	  


Right now I'm just linking to so the user can enter the info manually, but I'd like the variable to make it auto.


Go to Top