setting smtp on php.ini with authentication

Dario Rusignuolo picture Dario Rusignuolo · Feb 12, 2013 · Viewed 15.5k times · Source

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 = [email protected]

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

Answer

Dario Rusignuolo picture Dario Rusignuolo · Feb 12, 2013

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