Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2007, 04:09 PM
Registered User
 
Join Date: Jun 2007
Location: Southampton, Hampshire, United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SMTP Authentication and mail()

Hi all,

On a website I am creating, the hosting service provides an SMTP server to use, along with a username and password, but it is not setup to allow the mail() function to be used.

Being able to send emails through PHP is a fundamental part of the site, so I've been searching around and trying to come up with some code to authenticate with the SMTP server to send the email. What I have at the moment is code found on the Internet to perform this task using the PEAR module. I assume this module is installed as the php.ini 'include_path' setting is c:\php4\pear. Please correct me if I am wrong:

Code:
    require_once "Mail.php";

    $from = "MySite Mailer <admin@mysite.com>";
    $to = 'mailto@mailto.com';

    $host = "smtp.mysite.com";
    $username = "smtp_user";
    $password = "smtp_pass";

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


The error I am getting is as follows:

Fatal error: sendmail(): Failed opening required 'Mail.php' (include_path='.;c:\php4\pear')

I do not have a file called Mail.php in my directory listing, but I assumed this would be included by default through PEAR? I have not used PEAR before, so am unsure.

Any help would be much appreciated.

-Will

 
Old July 31st, 2007, 10:06 AM
Registered User
 
Join Date: Jul 2007
Location: Dhaka, Dhaka, Bangladesh.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shimul39 Send a message via Yahoo to shimul39
Default

Why don't you try with PHPmailer (http://phpmailer.sourceforge.net/)

Its a Full featured email transfer class.

feel free to ask me if you have any further question on it.

Thanks

http://www.shimul.info




Similar Threads
Thread Thread Starter Forum Replies Last Post
sending email with SMTP authentication (port 26) crmpicco PHP How-To 3 November 4th, 2007 01:18 PM
Mail(SMTP) ajit Java Basics 2 October 24th, 2007 12:01 AM
Ch 11 SMTP SendMail Authentication Required sixiron BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 November 11th, 2006 09:57 AM
SMTP Mail with User Authentication ~Bean~ VB How-To 0 November 6th, 2003 10:24 AM
SMTP for mail() petercch Pro PHP 1 July 25th, 2003 06:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.