I assume you mean e-mail the link to the person. If you want to e-mail the actual page, that's a little different...
The most basic way to do e-mail a message would be to use the mail() function.
mail() takes a few parameters
- $to - the recipient's e-mail address
- $subject - the subject line (no newline characters!)
- $message - the body of the message
- $headers - a list of headers, including "From: myemail@domain.com"
So, you can gather the appropriate information with a form. For example, you might include an "e-mail this" link on a page. The user enters a "To:" and "From:" address, and the message and subject are created by the script.
Here's an example of it in action, with some hard-coded variables...
$to = "your-email@domain.com";
$subject = "Hey! Check out this cool site.";
$message = "I found this site at http://mysite.com. Check it out!";
$headers = "From: my-email@domain.com";
mail($to, $subject, $message, $headers);
That's all there is to it. Now just have your script populate those variables with the form information and you're good to go.
For some more examples, go read about mail() on php.net.
Walkere
Junior Poster in Training
57 posts since Jan 2008
Reputation Points: 29
Solved Threads: 5
Skill Endorsements: 0
u know it is not gonna work if your server is not configured to send email without authorization.
better u login and fast!
That is true. The simple mail() function won't work if you need authentication in order to send e-mails.
However, most SMTP servers don't require any type of authentication. If anything, they just check to see that the origin of the message is from inside the network.
I've been able to use the mail() function perfectly fine on a free host (Frihost.com) and a paid host (ixwebhosting.com). Neither required SMTP authentication.
- Walkere
Walkere
Junior Poster in Training
57 posts since Jan 2008
Reputation Points: 29
Solved Threads: 5
Skill Endorsements: 0
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 357
Skill Endorsements: 18
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 357
Skill Endorsements: 18
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 357
Skill Endorsements: 18