Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Contact Form - From Address Help

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

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

Page: 1 2
Go to End
Author Topic: 3231 Views
  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Contact Form - From Address Help Link to this post

    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 pastie.org 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...

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Contact Form - From Address Help Link to this post

    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.

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Contact Form - From Address Help Link to this post

    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.

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Contact Form - From Address Help Link to this post

    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:

    http://pastie.org/246883

    Maybe this will work!

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Contact Form - From Address Help Link to this post

    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.

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Contact Form - From Address Help Link to this post

    Great to hear!

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

    Sean

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Contact Form - From Address Help Link to this post

    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();
    $form->saveInto($member);
    $member->write();

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

    Director::redirect('/thanks-for-signing-up/');
    }

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

    Possible?

    3231 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.