| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 141991 | 2016-04-08 02:28:00 | Add "Subscribe" button to my website | chiefnz (545) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 1418768 | 2016-04-08 02:28:00 | I'm trying to add a form which will allow users to subscribe to receive email updates and other information . Now before I get into the detail the first question I'll ask is . . . do i need to have a mail list set up on my server or via a service somewhere before this will work? Here is the html code for the form I intend to use . . . <form method="POST" action="subscribe . php"> <p>Name: <input type="text" name="Name" size="20"></p> <p>Email: <input type="text" name="Email" size="20"></p> <p><input type="submit" value="Submit" name="Submit"></p> </form> This is the content of the "subscribe . php" script, which I found via google search . . . . <?php ## CONFIG ## # LIST EMAIL ADDRESS $recipient = "info@mydomain . co . nz"; # SUBJECT (Subscribe/Remove) $subject = "Subscribe"; # RESULT PAGE $location = "index . html"; ## FORM VALUES ## # SENDER - WE ALSO USE THE RECIPIENT AS SENDER IN THIS SAMPLE # DON'T INCLUDE UNFILTERED USER INPUT IN THE MAIL HEADER! $sender = $recipient; # MAIL BODY $body . = "Name: " . $_REQUEST['Name'] . " \n"; $body . = "Email: " . $_REQUEST['Email'] . " \n"; # add more fields here if required ## SEND MESSGAE ## mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent . "); ## SHOW RESULT PAGE ## header( "Location: $location" ); ?> When I click the "Submit" button I get an error saying Mail could not be sent . Any ideas as to what I'm doing wrong or is my query about the mail list needing to be set up first the problem? Both the page which holds the form as well as the php script are located in /var/www/html I'm running CentOS 7, basic server with GUI, I have php, apache, mysql installed, apart from this little snag everything else is working fine on the website . Thanks, |
chiefnz (545) | ||
| 1418769 | 2016-04-08 05:06:00 | You could do what i did. Download a copy of Coffee Cup Form maker. make the form, and that's it :) | mzee (3324) | ||
| 1418770 | 2016-04-08 05:37:00 | I really hate the code tag here, it messes up mobile viewing, so i cant see what your subscribe.php is actually doing. Have a look in your mail.log, this should instantly pinpoint your problem. Have you setup your SMTP service? Postfix should be installed on CentOS, which uses the same name as sendmail in your binary location. Check your php config to ensure sendmail path is set properly. Send a test from within bash: echo test | mail -s test your@email.com That should make sure postfix is set up correctly. I guess seeing mail.log is crucial though. Cheers, KK |
Kame (312) | ||
| 1418771 | 2016-04-08 06:43:00 | Thanks guys, I decided to go with MailChimp; got everything setup, working and at no cost which is always a bonus. | chiefnz (545) | ||
| 1418772 | 2016-04-08 15:04:00 | If i were you, i would go with Jetpack subscription box. That works fine and unlimited subscribers can be mailed for free. Further it doesn't slow down you server. | newbiehelper (17464) | ||
| 1 | |||||