I know that to send e-mail from localhost on Windows, you need to change SMTP server in php.ini however this is valid only on Windows:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
So what I should do to be able send e-mails from Linux OS?
The PHPMailer library provides the easiest way to send an email from localhost with an SMTP server using PHP. Not only the text email, but you can also send HTML email from localhost in PHP using PHPMailer.
PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters. mail( to, subject, message, headers, parameters );
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.
I would suggest installing ssmtp rather than installing a full mail server like postfix. If this is just a local test environment, you probably don't need a full MTA. ssmtp is very easy to setup--you just supply your smtp credentials for a remote server. There's a tutorial here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With