Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending PHP mail from Windows server

I have a form on my page. When the user hits the Send button - it's supposed to send an email with the details he entered in the form. Up until recently the form was hosted on a Linux server and I had no problem with it - the mail was sent and received. Recently I had to move to shared Windows server and since the move the mail is not sent. Here's the code that supposed to send the mail:

function send_contact_form($strName, $strEmail, $strPhone, $strMessage)
{
$to = '[email protected]';
$subject = 'From the site';
$message =  '<html lang="HE">
            <head>
            <title>
                '.$subject.'
            </title>
            </head>
            <body style="text-align:right; direction:rtl; font-family: Arial;">
                Name: '.$strName.'<br>Email: '
                .$strEmail.'<br>Phone: '.$strPhone
                .'<br><br>Message: <br>'.$strMessage.'
            </body>
        </html>';       
$email = $strEmail;
$header  = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$header .= "From: $email\r\nReply-To: $email" . "\r\n";

mail($to, $subject, $message, $header);
}
like image 390
Igal Avatar asked Jun 16 '13 17:06

Igal


Video Answer


1 Answers

In a windows environment PHP uses SMTP insted of the Linux binary sendmail (or replacement)

You need to edit php.ini according to this page to be able to send e-mail via the mail() function.

like image 97
Fluff Avatar answered Oct 27 '22 00:10

Fluff