Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Send an email from you website



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> Script-archive
View previous topic :: View next topic  
Author Message
flabbyrabbit
500+ Club


Joined: 25 Jan 2007
Posts: 567
Location: UK

PostPosted: Mon Dec 24, 2007 1:11 pm    Post subject: Send an email from you website Reply with quote

This question has been ask so often, so here it is.

Simple mail function, send a flat email.
PHP:
<?php
$to      
'to@hotmail.com'//address email should be sent to
$subject 'subject here'//Subject of the email
$message 'enter the message here'//The message
//These extra headers allow you to set who the message is from
$headers 'From: webmaster@example.com' "\r\n" .
    
'Reply-To: webmaster@example.com' "\r\n" .
    
'X-Mailer: PHP/' phpversion();
//"From" is address that the email would have been sent from
//"Reply-To" is the address that any replies will be sent to
//This line sends your message
mail($to$subject$message$headers);
?>

This wont be very useful to most people, as it is very rarely you want to sent the same email to one person repeatedly.

So next i will show you how to create a form that will be used to send the email. I this example i will use a contact form on a web page that allows visitors to send a message to the owner.

First create a page called contact.php, then enter this code:
Code:
<form method=POST action="send.php">
Email: <input name="email"><br>
Subject: <input name="subject"><br>
Message:<br>
<textarea name="message" cols=40 rows=6></textarea><br>
<input type=submit value="send">
</form>

Then make another page called send.php:
PHP:
<?php
$to 
='nosmo-kings@hotmail.com'//Your email address (webmasters email address)
$subject $_POST['subject']; //Gets the subject sent by the form
$message $_POST['message']; //Gets the message sent by the form
$headers 'From: ' $_POST["email"] . "\r\n" .
'Reply-To: ' $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' phpversion();
//Changes the reply to email so the webmaster can easily reply
mail($to$subject$message$headers);
//Shows a message when email is sent
echo "message sent";
?>

Now the contact form should be up and running. Emails may be placed in recipients junk mail box for security reasons.

I hope this answers everyones questions, but if you need any more help don't hesitate to ask,
Flabby Rabbit
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
anonymousnewbie



Joined: 10 Dec 2007
Posts: 4

PostPosted: Mon Dec 31, 2007 10:02 pm    Post subject: Re: Send an email from you website Reply with quote

i think I'm too stupid..
may i know what is the good start for me to learn any basic programming language...do i need to download or installed it?can we start with notepad?i make a research that notepad can save to certain program like .vbs, .bat.
is any other?
Back to top
View user's profile Send private message
Johnathan
500+ Club


Joined: 31 May 2007
Posts: 916
Location: Belfast, Northen Ireland

PostPosted: Tue Jan 01, 2008 11:27 pm    Post subject: Re: Send an email from you website Reply with quote

Yea you can use notepad. Save it as .php the way you save the other stuff in different formats like .html, .vbs and so on.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
DDragon
50+ Club


Joined: 20 Jun 2007
Posts: 90
Location: Australia

PostPosted: Wed Feb 20, 2008 3:53 am    Post subject: Re: Send an email from you website Reply with quote

ok. i have tried this out and have not got it working properly. with the 'contact.php' is there any php scripting needed? as i am new to PHP scripting and am not sure what to do with it.

Thanks DD
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
webmaster
Site Admin


Joined: 17 Aug 2004
Posts: 3612
Location: Sweden

PostPosted: Wed Feb 20, 2008 9:42 am    Post subject: Re: Send an email from you website Reply with quote

The only changes in the PHP-script you'll have to do is to change the e-mail in:
$to ='nosmo-kings@hotmail.com';
Back to top
View user's profile Send private message Visit poster's website
leonard
100+ Club


Joined: 18 Dec 2007
Posts: 147
Location: Switzerland

PostPosted: Wed Mar 12, 2008 2:50 pm    Post subject: Re: Send an email from you website Reply with quote

If you don't want your emails to be marked as spam when they are received, you may want to have a look at this topic:

http://www.devppl.com/forum/how-to-avoid-being-spam-vt9653.html

cheers!
- leonard
Back to top
View user's profile Send private message Visit poster's website
DDragon
50+ Club


Joined: 20 Jun 2007
Posts: 90
Location: Australia

PostPosted: Sat Jun 14, 2008 5:20 am    Post subject: Re: Send an email from you website Reply with quote

Ok i have a large form i need this script for. DO i have to input each individual field into the script or will it take all fields into the message and send as is?

DD
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Johnathan
500+ Club


Joined: 31 May 2007
Posts: 916
Location: Belfast, Northen Ireland

PostPosted: Sat Jun 14, 2008 10:47 am    Post subject: Re: Send an email from you website Reply with quote

You need to put all the individual fields into the script. Well the ones you want to get from your user...
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
DDragon
50+ Club


Joined: 20 Jun 2007
Posts: 90
Location: Australia

PostPosted: Sat Jun 14, 2008 11:59 am    Post subject: Re: Send an email from you website Reply with quote

lol ok now i see *points to self* learn to friggen read sip**** lol
thanks john
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> Script-archive All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap