Wysyłanie mejli z localhost

0

Hej,

próbuję wysłać za pomocą formularza, mejla do klienta (w ramach testów na mojego mejla) z localhosta.

Jako serwer używam xamppa, został skonfigurowany zgodnie z tym opisem

 You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP. So if you are using XAMPP then you can easily send mail from localhost.

for example you can configure C:\xampp\php\php.ini and c:\xampp\sendmail\sendmail.ini for gmail to send mail.

in C:\xampp\php\php.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.

in php.ini file find [mail function] and change

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with following code

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]
Now you have done!! create php file with mail function and send mail from localhost.

PS: don't forgot to replace my-gmail-id and my-gmail-password in above code. Also, don't forget to remove duplicate keys if you copied settings from above. For example comment following line if there is another sendmail_path : sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" in the php.ini file

Also remember to restart the server using the XAMMP control panel so the changes take effect.

W programie wysyłka mejli jest opisana w ten sposób:

 if(!empty($_POST['mejl']))
        {
            $adresy = '';
            $temat = '';
            $tresc = '';
                if(!empty($_POST['adresy'])) {
                    $adresy = $_POST['adresy'];
                }
                if(!empty($_POST['tytul'])) {
                    $temat = $_POST['tytul'];
                }
                if(!empty($_POST['tresc'])) {
                    $tresc = $_POST['tresc'];
                }

            if($adresy !="" && $temat != "" && $tresc != "")
            {
                if(mail($adresy, $temat, $tresc)){
                    echo "<b>Wysłano</b><br><br>";
                }
            }
            else
            {
                echo "<b>Wypełnij wszystkie pola!</b><br><br>";
            }

               

        }

Niestety mimo wyświetlenia się komunikatu "Wysłano" nie otrzymuję mejla na skrzynkę pocztową.

Da się z localhosta wysyłać wg tego poradnika mejle? Co nie tak zrobiłem? :S

Proszę o pomoc

2

Nie korzystaj z mail :P

0

Ok, dzięki. Do zamknięcia.

1 użytkowników online, w tym zalogowanych: 0, gości: 1