Configuring smtp on windows-7 iis-7.5

I configured the php / mysql application on my local laptop using iis7 for testing. I am using php mail () to send email using the localhost smtp service on the server and want to replicate locally for testing. (It worked great for a long time on the server, so I just want to replicate locally for testing purposes.)

Using the technology article: http://technet.microsoft.com/en-us/library/cc772058(WS.10).aspx I was able to configure SMTP settings, but I still can’t send an email.

I reused the server several times without effect.

I ran netstat -an and there is nothing to listen on port25 - is there anything else I need to do to get the smtp service to listen on port25?

The error I get is:

PHP Warning: mail () [function.mail]: Failed to connect to the mail server named "localhost". port 25, check your "SMTP" and "smtp_port" installation in php.ini or use ini_set ()

php.ini:

SMTP = localhost
smtp_port = 25
+5
source share
3 answers

You can use something like smtp4dev (http://smtp4dev.codeplex.com/) instead of iis for testing purposes. Works like a charm to me.

+16
source

Windows 7 SMTP. . , , , .

+2

, OP. , W7 ( Ultimate) SMTP- ( , Vista 64 Ultimate , , XP), , .

, IIS7 IIS7 Express:

$smtpserver = 'host.domain.tld';
$port = 25;
$from = 'mailbox@domain.tld';
$replyto = $from;
$headers = 'From: ' . $from . "\r\n" . 'Reply-To: ' . $replyto . "\r\n" . 
    'X-Mailer: PHP/' . phpversion();
$to = 'mailbox@domain.tld';
$subject = 'Test Message';
ini_set('SMTP', $smtpserver);
ini_set('smtp_port', $port);
$message = wordwrap("Hello World!", 70);
$success = mail($to, $subject, $message, $headers);

( TLS/SSL), , PHP:

ini_set('username', 'yourusername');
ini_set('password', 'yourpwd');

TLS/SSL , GMail, Sourceforge xpm4 . GMail ( , ):

// manage errors
error_reporting(E_ALL); // php errors
define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
// path to 'MAIL.php' file from XPM4 package
require_once '../MAIL.php';
// initialize MAIL class
$m = new MAIL;
// set from address
$m->From('username@gmail.com');
// add to address
$m->AddTo('client@destination.net');
// set subject
$m->Subject('Hello World!');
// set HTML message
$m->Html('<b>HTML</b> <u>message</u>.');
// connect to MTA server 'smtp.gmail.com' port '465' via SSL ('tls' encryption)
// with authentication: 'username@gmail.com'/'password'
// set the connection timeout to 10 seconds, the name of your host 'localhost'
// and the authentication method to 'plain'
// make sure you have OpenSSL module (extension) enable on your php configuration
$c = $m->Connect('smtp.gmail.com', 465, 'username@gmail.com', 'password', 'tls', 10,
            'localhost', null, 'plain')
        or die(print_r($m->Result));
// send mail relay using the '$c' resource connection
echo $m->Send($c) ? 'Mail sent !' : 'Error !';
// disconnect from server
$m->Disconnect();

IIS7 Express ( , ). FastCGI PHP OpenSSL Extension. HTML- . xpm4 ( , ):

// manage errors
error_reporting(E_ALL); // php errors
define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
// path to 'SMTP.php' file from XPM4 package
require_once '../SMTP.php';
$f = 'username@gmail.com'; // from (Gmail mail address)
$t = 'client@destination.net'; // to mail address
$p = 'password'; // Gmail password
// standard mail message RFC2822
$m = 'From: '.$f."\r\n".
     'To: '.$t."\r\n".
     'Subject: test'."\r\n".
     'Content-Type: text/plain'."\r\n\r\n".
     'Text message.';
// connect to MTA server (relay) 'smtp.gmail.com' via SSL (TLS encryption) with 
// authentication using port '465' and timeout '10' secounds
// make sure you have OpenSSL module (extension) enable on your php configuration
$c = SMTP::connect('smtp.gmail.com', 465, $f, $p, 'tls', 10) or die(print_r($_RESULT));
// send mail relay
$s = SMTP::send($c, array($t), $m, $f);
// print result
if ($s) echo 'Sent !';
else print_r($_RESULT);
// disconnect
SMTP::disconnect($c);

GMail , IIS7 .

+1

All Articles