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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Replace from address on Userdefinedform


Go to End


4 Posts   2529 Views

Avatar
noizy

Community Member, 25 Posts

8 April 2008 at 2:07pm

I've got a contact form with all the usual suspects: name, email, enquiry.

When I send as an non-logged-in user, the 'from' address that appears in my email is the site AdminEmail I defined in my _config file...

Email::setAdminEmail('dev@breathecommunications.com');

But how/where do I write the code that will take the submitted email address, and use that as the from address?

I'm just using the standard ContactForm page type - do I need to extend that with my own pagetype and add some code in there, perhaps?

Avatar
Double-A-Ron

Community Member, 607 Posts

26 August 2008 at 10:15am

Bump and subscribe

Avatar
Liam

Community Member, 470 Posts

26 August 2008 at 4:41pm

I wanted to do the same thing. You can't do it with the userdefined form, you must write your own code.

I've attached how my file turned out. Be sure to make your email template in mysite/templates/email named ContactPage_Email or whatever you want to change it to.

The code isn't commented, so if you don't understand some things, let me know.

Avatar
Liam

Community Member, 470 Posts

26 August 2008 at 4:43pm

Hmm didn't upload the first time.