inherit
163931
0
Feb 23, 2011 14:01:52 GMT -8
smokekills
9
February 2011
smokekills
|
Post by smokekills on Feb 21, 2011 17:27:43 GMT -8
This is continued from this thread: support.proboards.com/index.cgi?board=programming&action=display&thread=382982Alright, so here's the problem. I am trying to code up a PHP script that basically sends an email. Sounds basic, right? Here's the tricky part. Using HTML or any other code will simply just load your default mail client and try to send it with that, what I need is a script that sends it via my website. I'll try to explain, Name: (This will send me their name they type) Email: (Same as above) Submit: (This will be the button they press when they submit the fore-mentioned details.) What would need to happen is the PHP would need to include the data entered in the name, and email field, (after the user clicks the submit button) copy it, and paste it into a email that is sent to my email address. (My email needs to be hidden obviously) But this needs to be done server side, without opening the person's mail client. And then once the email is sent, they need to be re-directed to a page. Only problem is, I CANNOT code PHP to save my life, I know this script is possible I've had it done before but lost the script Much appreciated anyone who can help me out on this one!
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Feb 21, 2011 20:04:41 GMT -8
Save this as "mail.php" and upload to a hosting service with PHP support and mail() enabled (contact the host and ask them if it's enabled).
<?php $bounce = "http://example.com"; // URL for user to be sent to after submission if($_POST['email']){ mail("your@email.com","subject goes here","Name: ".$_POST['name']."\nEmail: ".$_POST['email']); header('Location:'.$bounce); } ?>
Put this where you want your form to go.
<form method="post" action="YOURDOMAIN.COM/mail.php"> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email" /><br /> <input type="submit" value="Submit" name="submit" /> </form>
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Feb 21, 2011 23:44:25 GMT -8
You forgot to actually do anything with $bounce.
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Feb 22, 2011 6:11:32 GMT -8
D'oh! Fixed Good catch.
|
|
inherit
163931
0
Feb 23, 2011 14:01:52 GMT -8
smokekills
9
February 2011
smokekills
|
Post by smokekills on Feb 22, 2011 17:36:25 GMT -8
Save this as "mail.php" and upload to a hosting service with PHP support and mail() enabled (contact the host and ask them if it's enabled). <?php $bounce = "http://example.com"; // URL for user to be sent to after submission if($_POST['email']){ mail("your@email.com","subject goes here","Name: ".$_POST['name']."\nEmail: ".$_POST['email']); header('Location:'.$bounce); } ?>
Put this where you want your form to go. <form method="post" action="YOURDOMAIN.COM/mail.php"> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email" /><br /> <input type="submit" value="Submit" name="submit" /> </form>
Thanks for taking time to help, it looks like the script is in working order it just does not send an email. :\
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Feb 22, 2011 18:29:30 GMT -8
You're positive that you've hosted the php file on a server that supports PHP and the PHP mail() function?
Also, I've found that emails might be flagged as spam when sent this way, or they may take a while to arrive.
|
|
inherit
163931
0
Feb 23, 2011 14:01:52 GMT -8
smokekills
9
February 2011
smokekills
|
Post by smokekills on Feb 22, 2011 18:31:54 GMT -8
yes, it is php friendly, idk about the mail() function, but it looks like I just got the test email, but half an hour later. Is there a way to speed it up or is that just up to my host? thanks malagrond
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Feb 22, 2011 18:46:53 GMT -8
I think it's up to your host, unfortunately, but no problem
|
|
inherit
163931
0
Feb 23, 2011 14:01:52 GMT -8
smokekills
9
February 2011
smokekills
|
Post by smokekills on Feb 22, 2011 18:51:54 GMT -8
I think it's up to your host, unfortunately, but no problem is there a better free host out there that let's you host php? I'm using ripway currently, and I still only got that 1 email, I haven't gotten anymore. any suggestions?
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Feb 22, 2011 18:54:51 GMT -8
Actually, I use 000webhost. It's one of the best free hosts out there. My parents use the free hosting package for their online business. I'm pretty sure the mail() function will be slow on all but dedicated hosts.
|
|
inherit
163931
0
Feb 23, 2011 14:01:52 GMT -8
smokekills
9
February 2011
smokekills
|
Post by smokekills on Feb 22, 2011 19:13:34 GMT -8
awesome! That site actually sends the mails asap. Thanks again man!
|
|