Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send email from localhost using PHP on Linux

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?

like image 866
Templar Avatar asked Aug 03 '11 08:08

Templar


People also ask

Can I send email from localhost PHP?

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.

How can I send an email using PHP?

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 );

Can I send email using localhost?

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.


1 Answers

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.

like image 85
Jacob Dalton Avatar answered Sep 29 '22 01:09

Jacob Dalton