How I send an email with PHP on windows server (windows Server Web 2008 and IIS 7.0) with smtp external server.
Into file : php.ini
I tried with this code, first time:[mail function]
; For Win32 only.
; SMTP = localhost
SMTP = mail.toto.com
; SMTP = 111.111.1.1
smtp_port = 25
Code: Select all
//echo $var_emaill;
//exit();
If (!empty($var_emaill))
{
$recipient = $var_emaill;
$subject = "confirmation …" ;
$msg = "hello \t$var_mr \t$var_name\n";
$msg .= "Email : \t$var_emaill\n";
$msg .= "thanks for your inscription\n\n";
$msg .= "Seconde ligne….." ;
$mailheaders = "From: toto.com<> \n";
//echo $msg;
//exit();
// send email
mail($recipient, $subject, $msg, $mailheaders);
}
And after, I tried an other solution :Server Error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
I installed “phpmailer » : C:\phpmailer\class.smtp.php
And I used an other code, this one :
Code: Select all
<?php
//echo $var_emaill;
//exit();
If (!empty($var_emaill))
{
//PHP Mailer
include ("C:\phpmailer\class.smtp.php");
// Preparation du mail
$mail = new PHPmailer();
$mail->IsSMTP();
$mail->Host='mail.toto.com';
$mail->From='toto.com';
$mail->AddAddress($var_emaill);
$mail->Subject='confirmation…';
$mail->Body='hello \t$var_mr \t$var_name\n';
if(!$mail->Send()){ //Test le return code de la fonction
echo $mail->ErrorInfo; //error message
}
else{
echo 'Mail sent with succes';
}
$mail->SmtpClose();
unset($mail);
}
?>
Server Error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
Can you help me :
How must I configure php.ini ?
must I configure class.smtp.php ? If yes how is it ?
my code php (my codes, the two above,) are there correct ?
Best Regards