Hi,
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
[mail function]
; For Win32 only.
; SMTP = localhost
SMTP = mail.toto.com
; SMTP = 111.111.1.1
smtp_port = 25
I tried with this code, first time:
//echo $var_emaill;
//exit();
If (!empty($var_emaill))
{
$recipient = $var_emaill;
$subject = "confirmation …" ;
$msg = "hello \ $var_mr \ $var_name\
";
$msg .= "Email : \ $var_emaill\
";
$msg .= "thanks for your inscription\
\
";
$msg .= "Seconde ligne….." ;
$mailheaders = "From: toto.com<> \
";
//echo $msg;
//exit();
// send email
mail($recipient, $subject, $msg, $mailheaders);
}
Here is an error message :
Server Error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
And after, I tried an other solution :
I installed “phpmailer » : C:\phpmailer\class.smtp.php
And I used an other code, this one :
<?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 \ $var_mr \ $var_name\
';
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);
}
?>
I have same error :
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