Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

PHP Mail - Serious problem

jandrews3jandrews3 Posts: 20Member
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:
[code]
<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient ";
$subject = "Hi!";
$body = "Hi,

How 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("

" . $mail->getMessage() . "

");
} else {
echo("

Message successfully sent!

");
}
?>
[/code]
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

Comments

  • pritaeaspritaeas Posts: 274Member
    : 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
Sign In or Register to comment.