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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:22:12+00:00 2026-05-24T16:22:12+00:00

I am trying to use PEAR Mail to send from my gmail address using

  • 0

I am trying to use PEAR Mail to send from my gmail address using below code,

<?php
include("Mail.php");
echo "This test mail for authentication";
try{
$from_name = "Test";
$to_name = "from name"; 
$subject = "hai"; 
$mailmsg = "Happy morning";



$From = "From: ".$from_name." <frommail@gmail.com>"; 
$To = "To: ".$to_name." <tomail@gmail.com>"; 

$recipients = "tomail@gmail.com"; 
$headers["From"] = $From; 
$headers["To"] = $To; 
$headers["Subject"] = $subject; 
$headers["Reply-To"] = "gunarsekar@gmail.com"; 
$headers["Content-Type"] = "text/plain"; 

$smtpinfo["host"] = "smtp.gmail.com"; 
$smtpinfo["port"] = "25"; 
$smtpinfo["auth"] = true; 
$smtpinfo["username"] = "mymail@gmail.com"; 
$smtpinfo["password"] = "mypassword"; 
//$smtpinfo["debug"]=True;
$mail_object =& Mail::factory("smtp", $smtpinfo); 

$mail_object->send($recipients, $headers, $mailmsg); 

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

}catch(Exception $e){
echo 'Caught exception: ',  $e->getMessage(), "\n";
}
echo "<br>Fin";
?>

this code not return any error or warning , it simply shows “Message successfully sent!”
but, mail not receiver to mail the address.

can any one please tell what problem in mycode or what actually happening.,

  • 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-24T16:22:13+00:00Added an answer on May 24, 2026 at 4:22 pm

    The first thing I see is that you have a mistake: Your check checks against an variable called $mail, but everything else refers to $mail_object. If that’s in your actual code, then I’m guessing that might be part of it.

    Some basic checks:

    • Did you check to make sure that you have POP or IMAP enabled in Gmail?
    • Have you set up this account with the same username and password on a normal machine, to ensure you can send and receive email outside of PHP?
    • Verify that you can even talk to the GMail server (that it isn’t blocked for some reason) by pinging smtp.gmail.com or using telnet to open a connection to port 25: telnet smtp.gmail.com 25
    • Read over the Gmail help for sending email.

    Beyond that, it looks like GMail requires TLS or SSL, which means you have to use port 587 or port 465. I don’t know if that package can handle encrypted connections, though. (Even on port 25, GMail requires SSL encryption.) That may preclude this from working at all.

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

Sidebar

Related Questions

I am trying to use PEAR Mail to send using an external smtp server.
I am trying to use this: include_once(PoliticalForum/StoredProcedure/User/number_login_attempts.php); Warning: include_once(../../untitled/sanitize_string.php) [function.include-once]: failed to open stream:
I am trying to install PEAR for use with PHP. As i read on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
I am trying to use SimpleTest with CodeIgniter, using code supplied by maroonbytes .
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
i'm using PEAR Mail_Queue, everything works great, except when i'm trying to send emails
i'm trying use webview to load a image from sdcard i use this path
I was trying use the code shown below to plot in such a way

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.