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

  • Home
  • SEARCH
  • 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 448939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:43:11+00:00 2026-05-12T21:43:11+00:00

I’m running fedora core 9 with php 5.2.6. I want to send a simple

  • 0

I’m running fedora core 9 with php 5.2.6. I want to send a simple email from a form using the php mail command.

Do I need to configure my system to be an smtp server? If so do I have to load something like pear?

I’ve read that pear is installed by default. however when I go to /usr/lib/php/pear , the folder is empty.

When I go to install pear with yum install php-pear none of the mirrors are available.

Does anyone have any suggesions on what mail service to use? If it’s installed by default and where I can figure out how to configure.

Thanks!
Joe

This the code I’m using:

    <?php

require_once('../class.phpmailer.php');
$mail = new PHPMailer(true);

$mail->IsSMTP();

try {
  $mail->SMTPAuth   = true;                  // enable SMTP authentication
  $mail->SMTPSecure = "tls";                 // sets the prefix to the servier
  $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
  $mail->Port       = "587";                 // set the SMTP port for the GMAIL server
  $mail->Username   = "joestestemail@gmail.com";  // GMAIL username
  $mail->Password   = "joeiscool";            // GMAIL password

  //This is the "Mail From:" field
  $mail->SetFrom('joestestemail@gmail.com', 'First Last');
  //This is the "Mail To:" field
  $mail->AddAddress('joe12345@mailcatch.com', 'John Doe');
  $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
  $mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";

  $mail->Send();
  echo "Message Sent OK<p></p>\n";
} catch (phpmailerException $e) {
  echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
  echo $e->getMessage(); //Boring error messages from anything else!
}

?>
  • 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-12T21:43:11+00:00Added an answer on May 12, 2026 at 9:43 pm

    I would strongly recommend using a library like PHPMailer to send emails.

    You can use it with the server’s own mail service or with any other server on the internet (your ISPs, Gmail, etc).

    For a better idea, check this example from their website:

    require_once('../class.phpmailer.php');
    $mail = new PHPMailer(true); // the true param means it will throw exceptions on     errors, which we need to catch
    
    $mail->IsSMTP(); // telling the class to use SMTP
    
    try {
      $mail->Host       = "mail.yourdomain.com"; // SMTP server
      $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
      $mail->SMTPAuth   = true;                  // enable SMTP authentication
      $mail->Host       = "mail.yourdomain.com"; // sets the SMTP server
      $mail->Port       = 26;                    // set the SMTP port for the GMAIL server
      $mail->Username   = "yourname@yourdomain"; // SMTP account username
      $mail->Password   = "yourpassword";        // SMTP account password
      $mail->AddReplyTo('name@yourdomain.com', 'First Last');
      $mail->AddAddress('whoto@otherdomain.com', 'John Doe');
      $mail->SetFrom('name@yourdomain.com', 'First Last');
      $mail->AddReplyTo('name@yourdomain.com', 'First Last');
      $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
      $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';     // optional - MsgHTML will create an alternate automatically
      $mail->MsgHTML(file_get_contents('contents.html'));
      $mail->AddAttachment('images/phpmailer.gif');      // attachment
      $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
      $mail->Send();
      echo "Message Sent OK<p></p>\n";
    } catch (phpmailerException $e) {
      echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
      echo $e->getMessage(); //Boring error messages from anything else!
    }
    

    Edit:

    Following up on your comment..
    For a simple GMail example, try this:

    require_once('../class.phpmailer.php');
    $mail = new PHPMailer(true);
    
    $mail->IsSMTP();
    
    try {
      $mail->SMTPAuth   = true;                  // enable SMTP authentication
      $mail->SMTPSecure = "tls";                 // sets the prefix to the servier
      $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
      $mail->Port       = 587;                   // set the SMTP port for the GMAIL server
      $mail->Username   = "yourusername@gmail.com";  // GMAIL username
      $mail->Password   = "yourpassword";            // GMAIL password
    
      //This is the "Mail From:" field
      $mail->SetFrom('name@yourdomain.com', 'First Last');
      //This is the "Mail To:" field
      $mail->AddAddress('whoto@otherdomain.com', 'John Doe');
      $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
      $mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
    
      $mail->Send();
      echo "Message Sent OK<p></p>\n";
    } catch (phpmailerException $e) {
      echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
      echo $e->getMessage(); //Boring error messages from anything else!
    }
    

    Edit2:

    The reason why you’re getting this error is because you have an extra ‘ on your string:

    Replace

    $mail->Host = "'smtp.gmail.com";
    

    with:

    $mail->Host = "smtp.gmail.com";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.