www.webdeveloper.com
Results 1 to 6 of 6

Thread: sending e-mail via php...issues

  1. #1
    Join Date
    Apr 2006
    Posts
    15

    sending e-mail via php...issues

    Hello,

    I need to send e-mail via php script. The mail server requires smtp authentication. I am using the pear package to do this but I am having some problems. I receive this error when I try to execute the script:

    Call to undefined method PEAR_Error::send()

    Pear is installed on the server. How do I get this working? Any particular server settings I need to consider? Thanks for the help.

    PHP Code:
    <?php
    require_once "Mail.php";

    $from "myname <myname@myname.com>";
    $to "yourname <yourname@yourname.com>";
    $subject "Hi!";
    $body "Hi,\n\nHow are you?";

    $host "mail.myhost.com";
    $username "user";
    $password "password";

    $headers = array ('From' => $from,
      
    'To' => $to,
      
    'Subject' => $subject);
    $smtp Mail::factory('smtp',
      array (
    'host' => $host,
        
    '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. #2

    PHP Mail

    Do you specifically know why you need to use SMTP at all to process this email. PHP mail() function should work perfectly if your server uses PHP. Some situations this might not be the case. Try this script:

    <?php
    $to = "recipient@example.com";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    if (mail($to, $subject, $body)) {
    echo("<p>Message successfully sent!</p>");
    } else {
    echo("<p>Message delivery failed...</p>");
    }
    ?>

    That script is very very raw. And would allow for spam. But it does use the php mail() function to work. It works fine for me.

    Blake France
    Western Kentucky Web Design

  3. #3
    Join Date
    Oct 2007
    Posts
    113
    I also try to switch to PEAR mail from php mail(). But what i dont understand is

    PHP Code:
    require_once "Mail.php"
    What is this and where should i get this file if i have to have such a file?

  4. #4
    Join Date
    Feb 2005
    Location
    Tauranga
    Posts
    2,062
    Quote Originally Posted by mrtblt
    I also try to switch to PEAR mail from php mail(). But what i dont understand is

    PHP Code:
    require_once "Mail.php"
    What is this and where should i get this file if i have to have such a file?

    require_once is similar to include
    http://php.net/require_once
    http://php.net/include

    mail.php? I guess holds your mail functions?


    Quote Originally Posted by pulleys
    Call to undefined method PEAR_Error::send()
    Are you sue the PEAR Mail Library is installed ?

  5. #5
    Join Date
    Oct 2007
    Posts
    113
    Of course i know what is "require_once" or "include"

    But what i wanted to as was something else. This "mail.php" is a certain file which i have to download from somewhere?

    To utilize pear mail function, do i need that certain "mail.php"?

  6. #6
    Join Date
    Oct 2011
    Posts
    1
    the Mail.php file is included in the pear install package

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles