PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1845
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
PHP Mail - Serious problem Posted by jandrews3 on 9 Aug 2008 at 9:04 AM
I've got a serious problem trying to use the mail() function. The new VPS server I'm using requires authentication. This nullifies the mail() function's usefulness, I'm told. The company tells me that they cannot disable the authentication requirement for my account, and suggested the following solution, found at http://email.about.com/od/emailprogrammingtips/qt/et073006.htm:
<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "ssl://mail.example.com";
$port = "465";
$username = "smtp_username";
$password = "smtp_password";

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

I'm really having a hard time understanding this script and making it work. Frankly, I'd rather just disable authentication, but that is apparently not an option. SO, HERE'S WHERE I'M AT: The solution script they suggested begins with a require_once"Mail.php" command, BUT WHAT IS THIS FILE? Where do they say what's in it? How can I require a file that I don't have. As usual, I'm sure the solution is easy for others to understand, but my limited experience with this makes it VERY VERY difficult. I NEED HELP PLEEEEEEASE!

Thanks for your help.
- James Andrews
Report
Re: PHP Mail - Serious problem Posted by pritaeas on 14 Aug 2008 at 5:54 AM
: I'm really having a hard time understanding this script and making
: it work. Frankly, I'd rather just disable authentication, but that
: is apparently not an option. SO, HERE'S WHERE I'M AT: The solution
: script they suggested begins with a require_once"Mail.php" command,
: BUT WHAT IS THIS FILE? Where do they say what's in it? How can I
: require a file that I don't have. As usual, I'm sure the solution is
: easy for others to understand, but my limited experience with this
: makes it VERY VERY difficult. I NEED HELP PLEEEEEEASE!

It appears they are using the PEAR (pear.php.net) Mail package. If you don't want to install PEAR, then have a look at PHPMailer. This tool can help you achieve the same.

Regards, Hans



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.