We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,688 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Forwarding a web page to a friend's e-mail

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

7
Contributors
13
Replies
2 Years
Discussion Span
2 Years Ago
Last Updated
14
Views
Dilnesaw
Newbie Poster
9 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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!

fatihpiristine
Posting Whiz in Training
283 posts since Sep 2007
Reputation Points: 6
Solved Threads: 19
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

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

Dilnesaw
Newbie Poster
9 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

byanothername
Newbie Poster
3 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

There.

nav33n
Purple hazed!
Team Colleague
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 357
Skill Endorsements: 18

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

best wishes
Mike

byanothername
Newbie Poster
3 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Wow! great.. :P

nav33n
Purple hazed!
Team Colleague
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 357
Skill Endorsements: 18

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

byanothername
Newbie Poster
3 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Yep. Possible.

nav33n
Purple hazed!
Team Colleague
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 357
Skill Endorsements: 18

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!

danielwalters6
Newbie Poster
4 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

Dilnesaw
Newbie Poster
9 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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!

elmerthomas
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0970 seconds using 2.71MB