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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:41:06+00:00 2026-05-25T13:41:06+00:00

<?php require_once Mail.php; $from = <niko@gmail.com>; $to = <niko@hotmail.com>; $subject = Hi!; $body =

  • 0
<?php
    require_once "Mail.php";
    $from = "<niko@gmail.com>";
    $to = "<niko@hotmail.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "<niko@gmail.com>";
    $password = "somepassworrd";
    $headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
    $smtp = Mail::factory('smtp', array ('host' => $host,'port' => $port,'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>");
?> 

When I try to execute these php script I get these error

  FATAL ERROR Class Mail NOT found ON number line 18

I know the above question is possible duplicate of these

Send email using the GMail SMTP server from a PHP page

But its not working.My PHP version is 5.3.4 Xampp 1.7.4 version.

 mail('caffeinated@example.com', 'My Subject', $message); \\ I tried these

But it shows a warning saying that missing headers.

  1. How do I send an email Using the php script?

  2. Can we send an email without using authentication in PHP ? Because vb.net uses server authentication but most of the code i found on google is without authentication for php. so I got a doubt

Finally please help me with these trying from an 2 hours or so!

  • 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-25T13:41:07+00:00Added an answer on May 25, 2026 at 1:41 pm

    The PHP mail() function is for sending mail via Sendmail. If you want to use some SMTP server, you can use Zend_Mail which makes this thing very easy:
    http://framework.zend.com/manual/en/zend.mail.html

    Using Zend_Mail you only need to write something like this:

    $config = array('auth' => 'login',
                'username' => 'myusername',
                'password' => 'password');
    
    $transport = new Zend_Mail_Transport_Smtp('mail.server.com', $config);
    
    $mail = new Zend_Mail();
    $mail->setBodyText('This is the text of the mail.');
    $mail->setFrom('sender@test.com', 'Some Sender');
    $mail->addTo('recipient@test.com', 'Some Recipient');
    $mail->setSubject('TestSubject');
    $mail->send($transport);
    

    The above handles authentication for you and sends a mail.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

require_once('phpmailer/class.phpmailer.php'); function smtpmailer($to,$from,$subject,$body) { define('GUSER', 'xxx'); // Gmail username define('GPWD', 'xxx'); // Gmail password
I have this script: require_once Mail.php; $from = Stephen <username@nvrforget.com>;//Google apps domain $to =
Here is my code: <?php require_once 'Swift/lib/swift_required.php'; $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465) ->setUsername('me@ff.com') ->setPassword('pass'); $mailer
I am trying to send an email via GMail's SMTP server from a PHP
<?php require_once '../plugin/swift/lib/swift_required.php'; // Create the Transport $transport = Swift_SmtpTransport::newInstance('pod51003.outlook.com',587,'tls') ->setUsername('user@connect.polyu.hk') ->setPassword('pw') ; //
I have some files: core.php : require_once 'logger.php'; require_once 'smth_else.php'; $Logger = new Logger();
My form class: <?php require_once ('Zend\Form.php'); class Sergio_Form_registrationform extends Zend_Form { public function init(){
Simple question: Is the scope of require_once global? For example: <?PHP require_once('baz.php'); // do
index.php: <form action=update_db.php method=post> <?php require_once 'modules/' . $currentModule . '.php'; ?> </form> modules/
Here's my Zend code: <?php require_once ('Zend\Form.php'); class Sergio_Form_registrationform extends Zend_Form { public function

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.