Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post

    SMTP Pear Gmail/Yahoo ERROR -- *HELP*

    I'm getting this error when ever I try to send email thru stmp.. tried both yahoo and gmail:

    Fatal error: Call to undefined method PEAR_Error::send() in /home/rapidcas/public_html/testmail.php on line 25
    I'm guessing Pear is already installed on my server, or else it would say it can't find the file...

    PHP Code:
    <?php

           
    require_once "Mail.php";

            
    $from "Mark Reddington <markman641@yahoo.com>";
            
    $to "Mark Reddington <markman641@gmail.com>";
            
    $subject "Hi!";
            
    $body "Hi,\n\nHow are you?";

            
    $host "smtp.mail.yahoo.com";
            
    $port "465";
            
    $username "markman641@yahoo.com";
            
    $password "xxxxxxxxxxxxxx";

            
    $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>");
             }

        
    ?>

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by markman641 View Post
    I'm guessing Pear is already installed on my server, or else it would say it can't find the file...
    It would only say it can't find the file if its your script that is including / requiring a file.

    PEAR is a PHP *module* so it acts slightly differently. In this case, the function you are trying to use from pear is undefined. Therefore your guess that its installed is probably wrong.

    Thats what phpinfo() is all about

    So.. on the assumption you don't have pear, I would recommend PHPMailer instead which does a wonderful job. Hit google and you'll have it downloaded in no time.

    As for Yahoo, they don't allow all users to use SMTP / POP3. They let some but not others. My account is from the age where they were trying to sell it as a premium service and I refused to upgrade when prompted. They've since deactivated my SMTP / POP3 access and despute newer accounts being allowed to use it, I remain unable because I refused to upgrade. GMail provides unrestricted access so thats your best choice.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • Users who have thanked tangoforce for this post:

    markman641 (09-09-2012)

  • #3
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Quote Originally Posted by tangoforce View Post
    It would only say it can't find the file if its your script that is including / requiring a file.

    PEAR is a PHP *module* so it acts slightly differently. In this case, the function you are trying to use from pear is undefined. Therefore your guess that its installed is probably wrong.

    Thats what phpinfo() is all about

    So.. on the assumption you don't have pear, I would recommend PHPMailer instead which does a wonderful job. Hit google and you'll have it downloaded in no time.

    As for Yahoo, they don't allow all users to use SMTP / POP3. They let some but not others. My account is from the age where they were trying to sell it as a premium service and I refused to upgrade when prompted. They've since deactivated my SMTP / POP3 access and despute newer accounts being allowed to use it, I remain unable because I refused to upgrade. GMail provides unrestricted access so thats your best choice.

    Hey thanks, I installed phpmailer... although im getting this error:

    SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
    SMTP Error: Could not connect to SMTP host. Mail error: SMTP Error: Could not connect to SMTP host.
    PHP Code:
    <?php

    require_once('phpmailer/class.phpmailer.php');
    define('GUSER''markman641@gmail.com'); // GMail username
    define('GPWD''XXXXXXXXXXXXXXX'); // GMail password
    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;
        }
    }


    if (
    smtpmailer('markman641@yahoo.com''markman641@gmail.com''Mark Reddington''test mail message''Hello World!')) {
        
    // do something
    }
    if (!empty(
    $error)) echo $error;
        
    ?>
    Last edited by markman641; 09-08-2012 at 12:24 AM.

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Are sockets / fopen enabled on your server?

    does file_get_contents('www.any_site_u_can_think_of.com') work?

    Might be an idea to enable smtp debug.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • Users who have thanked tangoforce for this post:

    markman641 (09-09-2012)

  • #5
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Quote Originally Posted by tangoforce View Post
    Are sockets / fopen enabled on your server?

    does file_get_contents('www.any_site_u_can_think_of.com') work?

    Might be an idea to enable smtp debug.
    I had to ask to get file_get_contents enabled and they did it.
    http://rapidcashgpt.com/info.php

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by markman641 View Post
    I had to ask to get file_get_contents enabled and they did it.
    Suggesting that your server is heavily locked down. I suspect you need to contact your host to get this resolved. If you dive into the source of phpmailer you'll see the only place it raises that exception is in the SmtpConnect function:
    PHP Code:
            if (!$connection) {
              throw new 
    phpmailerException($this->Lang('connect_host'));//This line 
    Basically, as the message says, PPMailer can't make a connection to google.

    With that said, I'm off for the night.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • Users who have thanked tangoforce for this post:

    markman641 (09-09-2012)

  • #7
    New Coder
    Join Date
    Aug 2007
    Posts
    49
    Thanks
    6
    Thanked 1 Time in 1 Post
    Hi I have also tried sending email throught SMTP but when my body contains $1,000,000 it won't send an email. but when i deleted 1 zero it would work.

    Do I have to configure something so that it would work if I send message containing money?

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Unless you show us your source code there is nothing we can do to help you. As for the extra 0, it won't be a php setting, it's an error in your code somewhere somehow I suspect.

    As the $ sign denotes a php variable, you should ensure that your $1000,000 is in a single quoted string instead of using double quotes.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •