php send mail from localhost

email, php

Solution

You must change the php.ini file:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain

It won't work if localhost is set, for that reason change to your mail server.

Problem

I am new at php. I was trying to send mail from php using this code. ``` <?php $to = 'sohil@gmail.com'; $subject = 'The subject'; $message = 'hello'; $headers = 'From: sohil@yahoo.in' . "\r\n" . 'Reply-To: receiver@yahoo.in' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> ``` I have change settings in php.ini ``` [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = sohil@gmail.com ``` & in sendmail.ini ``` # A freemail service example account Gmail tls on tls_certcheck off host smtp.gmail.com from sohil@gmail.com auth on user sohil@gmail.com password xxxxxxxxx # Set a default account account default : Gmail ``` Now code runs successfully but I am not getting any mail.

Original source

Related problems