Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7648659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:46:26+00:00 2026-05-31T10:46:26+00:00

I trying to make a tell a friend script. The script must send an

  • 0

I trying to make a tell a friend script.

The script must send an email to the address the user specifies in the form field. containing the link of the current page in the mail body.

I tried a lot of scripts and mail classes like phpmailer, etc..

But couldnt make any of them works…

Can someone help me?

UPDATE: this is my current code

<?php
require_once 'Mail.php';

$from = "xxx@xxxx.com.";

$to = $_POST["email"];
$subject = "Pear mail test";
$body = "testing pear mail. if you are reading this, it is working.";

$host = "smtp.xxxxxx.com";

$username = "xxx@xxxx.com.";
$password = "xxxxx";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);

$smtp = Mail::factory('smtp',
  array ('host' => $host,
  'port' => '587',
    'auth' => true,
    'username' => $username,
    'password' => $password));
$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
 ?>

<form action="<?php echo $PHP_SELF?>" method="post">
<fieldset>
        <legend>Recomendar</legend>
         <label for="nome">Nome</label><input name="nome" size="40" type="text" />
         <label for="email">E-mail:</label><input name="email" size="40" type="text" />
         <input type="submit" value="Enviar" />
</fieldset>
</form>

it works, but the script is activated when loading the page (return a recipient error), how can i make the script run only when user press the submit button?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:46:28+00:00Added an answer on May 31, 2026 at 10:46 am

    Pear Mail is pretty easy to use if it’s available to you

    http://pear.php.net/manual/en/package.mail.mail.factory.php

    $headers = array
      ( "Subject" => $subj,
        "To" => $to,
        "From" => "Your Name <{$from}>",
        "Content-Type" => "text/plain",
        "MIME-Version" => "1.0"
        );
    
    $message = "Hello, world";
    
    $smtp = Mail::factory
      ( "smtp",
        array
        ( "host" => "???",
          "port" => 465,
          "auth" => true,
          "username" => $from,
          "password" => $pass
         )
        );
    
    $mail = $smtp->send($to, $headers, $message);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a little desktop alert script that will tell me
I am trying to build a 'Tell a Friend' form for my Sitecore site
I'm trying to make a method that will tell me weather or not it
Can someone tell/show me how to use PHP inside PHP. I'm trying to make
Trying to make a custom :confirm message for a rails form that returns data
I'm trying to make a macro in C that can tell if a char
I'm trying to make a hash function so I can tell if too lists
In objective C, I'm trying to make something hide from view. Could anyone tell
I'm trying to make a complex calculator and the user has to select from
I'm trying to make an application which allows the user to draw shapes to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.