Can somebody just drop me a code that I can use to forward a web page to some body's e-mail ? I am still a beginner for PHP. If you are not able to give the codes, I appreciate if I can get the general direction.

Thank you very much.

Dilnesaw

Recommended Answers

All 13 Replies

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.

Member Avatar for fatihpiristine

u know it is not gonna work if your server is not configured to send email without authorization.

better u login and fast!

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

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.

Thank you so much. I will try this. Hopefully it will work.

Dilnesaw

where is the information in this script which refers to the actual url of the page you wish to send on to a friend?


best wishes
Mike

$message = "I found this site at http://mysite.com. Check it out!";

There.

Thank you. I shall continue to do my good work for the Universe.

best wishes
Mike

Wow! great.. :P

seriously though, thanks for the tip.
I was hoping to use a php script so that people could make up their own quotes on this page http://www.sixtysixninetynine.com/, then submit them to the site and/or email the link to a friend. I think php could be used to display the page with the new quotes in it - ie so they could view a live page, before sending it on to someone else. Th epart they would replace with thie rown quotes would be "I see that French trader lost the bank nearly 5 billion Euros."
"Do you mean they won't make a profit?"
any thoughts on that?

best wishes
Mike

Yep. Possible.

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.

Brilliant code - easy to use an understand, have tweaked for my own purpose!

Thank you Walkere for the iformation you posted. I am going to test if it works. I appreciate.
Dilnesaw

The limits of my website building
skills - using templates and simple
programs like yahoo sitebuilder.

All I want to do is put a business card
size box on my page so that peole can
forward my page to each other.

Help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.