使用身份验证在php.ini上设置smtp

I'm setting up smtp on IIS web server using php

In the php.ini file the smtp section as follow:

[mail function]
SMTP = outbound.mailhop.org
smtp_port = 25

auth_username = my_dyndns_username
auth_password = pwd

sendmail_from = no-reply@website.com

The problem is that when I try to call the mail() function the smtp server says

SMTP server response: 550 You must authenticate to use Dyn Standard SMTP

where can I tell IIS (or php) the username and password in order to be authenticated on dyndns server?

Dario

To use SMTP Authentication with PHP you'll want to use the Mail PEAR extension ... here is a nice post telling you how to use it.

Basically, you'll need to install the extension (windows instructions) and then configure a bit of code something like this (from the post above):

<?php
 require_once "Mail.php";

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

How are you?";

 $host = "mail.example.com";
 $username = "smtp_username";
 $password = "smtp_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>");
  }
 ?>

I found swift mailer to be a solution form my problem.

with this simple script I have everything works

$transport = Swift_SmtpTransport::newInstance('outbound.mailhop.org', 25)
                ->setUsername('user')
                ->setPassword('pwd');

$mailer = Swift_Mailer::newInstance($transport);


$message = Swift_Message::newInstance()
        ->setSubject($sbj)
        ->setFrom($from)
        ->setReplyTo($replyTo)
        ->setTo($to)
        ->setBody($msg);

$result = $mailer->send($message);

here is the book on how to do with other functions/parameters