Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Harmush

macrumors 6502a
Original poster
Sep 21, 2008
557
3
Liverpool
Hey guys, i am doing some work for a church, mainly graphics but they have asked if i can make a little form for their site while i'm doing the graphics. I thouhgt i would give it a go but i can't get it to work.

Basically what i need, in HTML/Javascript (something that doesnt require loads of support files, i'd like it to work within one page), is one textbox and one button.
when someone enters an email address into the box and presses the button it sends a generic HTML email to that person, which can be stored on the sever. I don't know what the easiest way to do this is. I have some experience with simple visual basic, would that be an option?

thanks for the help.
 
Does the server have PHP, ASPX, Java, Python, or Ruby support?

If it has any of the above then it will be very easy to do once we know what you have access to.

PHP is probably the most common and if you don't know how to check just make a file called info.php and include the following.

PHP:
<?php
phpinfo();

If you get a return when you browse to that file you have PHP installed.
 
Does the server have PHP, ASPX, Java, Python, or Ruby support?

If it has any of the above then it will be very easy to do once we know what you have access to.

PHP is probably the most common and if you don't know how to check just make a file called info.php and include the following.

PHP:
<?php
phpinfo();

If you get a return when you browse to that file you have PHP installed.

server does support PHP, and ASPX
 
Then it is really simple.

mailer.php
PHP:
<?php
if (isset($_GET["sendmail"])):
    $address = $_POST["address"];
    $message = "This is a email";
    mail($address, 'Email Subject', $message);
else:
?>
<form action="mailer.php?sendmail" method="post" >
    <input type="text" name="address" />
    <button type="submit">Send Email</button>
</form>
<?php endif; ?>

You mite want to include some validation and test it, this is partly of memory but should work.
 
Then it is really simple.

mailer.php
PHP:
<?php
if (isset($_GET["sendmail"])):
    $address = $_POST["address"];
    $message = "This is a email";
    mail($address, 'Email Subject', $message);
else:
?>
<form action="mailer.php?sendmail" method="post" >
    <input type="text" name="address" />
    <button type="submit">Send Email</button>
</form>
<?php endif; ?>

You mite want to include some validation and test it, this is partly of memory but should work.

That is very simple and just what i was looking for! thank you.

how would i edit it to send an email with a html file. so the email is a html email basically. not plain text.

thank you very much.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.