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 9239487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:59:52+00:00 2026-06-18T07:59:52+00:00

I have installed apache-5.4.2, PHP-5.4.11 and Mysql-5.5.29 . I want to send mail using

  • 0

I have installed apache-5.4.2, PHP-5.4.11 and Mysql-5.5.29 . I want to send mail using php. I have realized that I need a SMTP server on my PC in order to send mails. Can anyone please tell me the details on how to install a SMTP server to send mail. Please give me details on it as I am new to this. Just FYI I am using the below code in PHP. Thanks.

<?php
$to = "xyz@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "abc@gmail.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?> 
  • 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-06-18T07:59:54+00:00Added an answer on June 18, 2026 at 7:59 am

    Assuming you have access to a standard email address, then you don’t need an SMTP server on your pc, you simply need to setup your details in the php.ini.

    If you open your php.ini file, and find this section;

    [mail function]
    SMTP = [Enter You Email SMTP address e.g. smtp.mymail.com]
    smtp_port = 25
    
    sendmail_from = [Enter your From Email Address e.g. me@mymail.com]
    
    auth_username = [Enter your Email Address UserName e.g. me1234] 
    auth_password = [Enter your Email Address Password e.g. password1234]
    

    If you enter in the values supplied for your regular email address (without the square brackets!), Restart your WebServer and PHP, then you should be up and running…

    EDIT:

    Seems as though GMAIL / Google Apps requires SSL to send email.

    As such, there’s a StackOverflow Question here.. How do I Send email using Gmail through mail() ? Where do I put the password?

    A full tutorial is here… http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/

    That has a full tutorial for sending email via gmail and PHPMailer. An excerpt from this is;


    1) If you don’t have one, register a GMail account or setup your domain
    for Google applications.

    2) Download a recent version of PHPMailer (I’m using the version 5.02)

    3) Check with your web hosting provider that port 465 (TCP out) is
    open, if not ask him to open that port

    4) Include the PHPMailer class file:

    require_once('phpmailer/class.phpmailer.php');
    

    5) Create those two constant variables to store your GMail login and
    password. Use the login for your Google Apps mail account if you
    have one.

    define('GUSER', 'you@gmail.com'); // GMail username
    define('GPWD', 'password'); // GMail password
    

    6) Use the following function to send the e-mail messages (add the
    function in one of your included files):

    function smtpmailer($to, $from, $from_name, $subject, $body) { 
        global $error;
        $mail = new PHPMailer();  // create a new object
        $mail->IsSMTP(); // enable SMTP
        $mail->SMTPDebug = 0;  // debugging: 1 = errors and messages, 2 = messages only
        $mail->SMTPAuth = true;  // authentication enabled
        $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
        $mail->Host = 'smtp.gmail.com';
        $mail->Port = 465; 
        $mail->Username = GUSER;  
        $mail->Password = GPWD;           
        $mail->SetFrom($from, $from_name);
        $mail->Subject = $subject;
        $mail->Body = $body;
        $mail->AddAddress($to);
        if(!$mail->Send()) {
            $error = 'Mail error: '.$mail->ErrorInfo; 
            return false;
        } else {
            $error = 'Message sent!';
            return true;
        }
    }
    

    Most of the settings inside the function are required by GMail. While searching for PHPmailer tutorials I found articles with different settings for the port and security. My advice is to use the settings from this tutorial.

    7) Call the function within your code:

    smtpmailer('to@mail.com', '', 'from@mail.com', 'yourName', 'test mail message', 'Hello World!');
    

    Use this more “advanced” usage inside your application:

    if (smtpmailer('to@mail.com', 'from@mail.com', 'yourName', 'test mail message', 'Hello World!')) {
        // do something
    }
    if (!empty($error)) echo $error;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed xampp on Windows7(64bit).I want to work with PHP, Apache and MySql.
I have installed native apache and mysql,php in my linux server. I tried a
I have installed Apache on my server (I wasn't using Apache) and special characters
I have an existing large(ish) PHP web app (using Apache and MySQL) which now
I have WAMP server installed in my PC. Apache Version : 2.2.17 PHP Version
I have XAMPP (Apache + MySQL + PHP) installed on my computer and I
I really need your help: I have installed easphp on my laptop (apache, php,
I installed XAMPP to run PHP from eclipse. I have a standalone MySQL server
The title describes the question. I have PHP installed, Apache, MySQL and also phpMyAdmin
I have apache, mysql, php installed manually on windows xp. How can I make

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.