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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:31:35+00:00 2026-06-02T02:31:35+00:00

My email will only send if I type in the actual address rather than

  • 0

My email will only send if I type in the actual address rather than using $usr_email, although it says ‘message sent’. The Email address comes from the user_email field in users table.
This is defined with
$id = intval($_SESSION[‘user_id’]);

if (isset($_POST['doSend'])) {


function getTwo($query){
    $res = mysql_query($query);
    if (!$res) {
        trigger_error("db: ".mysql_error()." in ".$query);
        return FALSE;
    }
    if ($row = mysql_fetch_row($res)) {
        return $row[0];
    }
}

$getuserinfo_q = "SELECT user_email AND user_name FROM users WHERE 
id='$_SESSION[user_id]'";

$getuserinfo_e=mysql_query($getuserinfo_q);

if(mysql_num_rows($getuserinfo_e) < 1){

    echo "User details not found - User_id is not in DB";

    exit();

}

$user_info_val=mysql_fetch_assoc($getuserinfo_e);

if(empty($user_info_val['user_email'])){

    echo "there is no such column name as 'user_email'"; //tell the user about column

    exit(); //shut off the script

}


$usr_email=$user_info_val['user_email'];
  $user_name=$user_info_val['user_name'];



$sqltest = "SELECT completed_status From users where id =
'$_SESSION[user_id]'";
$isSending = getTwo($sqltest);
$isSending === false;
if($isSending >= 6){
    require_once "Mail.php";
    require_once "Mail.php";



    $from = "<xxx>";
    $to = "$usr_email";
    $subject = "hi";
$body ="Chi ";

$host = "ssl://smtp.gmail.com";
$port = "465";
    $username = "xxx";
    $password = "xxxx";

 $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>");
    }
}
else
    header ("Location: error.php");



}
  • 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-02T02:31:37+00:00Added an answer on June 2, 2026 at 2:31 am

    BIG EDIT:

    OKAY, So lets hope this works -_-

    $getuserinfo_q = "SELECT user_email AND user_name FROM users WHERE id ='
    ".intval($_SESSION['user_id'])."'";
    
    $getuserinfo_e=mysql_query($getuserinfo_q);
    
    if(mysql_numb_rows($getuserinfo_e) < 1){
    
    echo "User details not found - User_id is not in DB";
    
    exit();
    
    }
    
    $user_info_val=mysql_fetch_assoc($getuserinfo_e);
    
    if(empty($user_info_val['user_email'])){
    
    echo "there is no such column name as 'user_email'"; //tell the user about column
    
    exit(); //shut off the script
    
    }
    
    
    $usr_email=$user_info_val['user_email'];
    
    
    $sqltest = "SELECT completed_status FROM users WHERE id ='
    ".intval($_SESSION['user_id'])."'";
    $isSending = getTwo($sqltest);
    $isSending === false;
    if($isSending >= 6){
        require_once "Mail.php";
    
    // Start NEW CLASS (for your weird Mail function)
    
    $m_class=new Mail;
    
    
        $from = "<xxx>";
        $to = "$usr_email";
        $subject = "hi";
    $body ="Chi ";
    
    $host = "ssl://smtp.gmail.com";
    $port = "465";
        $username = "xxx";
        $password = "xxxx";
    
     $headers = array ('From' => $from,
    'To' => $to,
    'Subject' => $subject);
    
    
    $smtp = $m_class->factory('smtp',
    array ('host' => $host,
        'port' => $port,
        'auth' => true,
        'username' => $username,
        'password' => $password));
    
    $mail = $m_class->send($to, $headers, $body);
    
    }
    else
        header ("Location: error.php");
    

    As you may have noticed, I removed the error checking ( the PEER::isError() thing) simply because I could not get my head around how that function should be called (not statically). But, other than that, the code above should do the trick (hopefully).

    Give it a go, and let me know how it works.

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

Sidebar

Related Questions

I'm sending an email using javascript. It will be sent via outlook but I
I am using a script in PHP that will allow me to send email,
I have to made a page which will send Email to Newsletter subscribers. There
I am trying to do a simple app that will send email. The constructor
my web application supposed to send email reminders in some point it will send
I'm developing an ASP.NET MVC application that will send the user a confirmation email.
I'm working with Perl on Windows. I will try to send mail with Email::Sender
I use asp.net's smtpClient to send email, but recently I found it can only
I am trying to send an email using c# using the following code. MailMessage
My iPhone app is using the MFMailComposeViewController class to send an in-app email with

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.