Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need a SMTP server in using the PHP's mail() function

Tags:

php

smtp

Do I need a SMTP server in using the PHP's mail() function?

p.s. I am on a share hosting account, so I cannot install a SMTP server and they don't provide that.

like image 493
Howard Avatar asked Jan 22 '23 16:01

Howard


2 Answers

PHP's mail() function doesn't need SMTP. It uses a program called sendmail which is generally available on Unix/Linux platforms by default and most web hosts provides this facility for no extra charge.

like image 173
Aditya Avatar answered Jan 24 '23 07:01

Aditya


PHP on Linux servers relies on a local MTA for the mail() function.

PHP on Windows can be configured to use whatever SMTP server you like.

PEAR::Mail allows you to set which SMTP server you want to use. http://pear.php.net/manual/en/package.mail.mail.intro.php

With the first parameter as 'smtp', the second param accepts details. http://pear.php.net/manual/en/package.mail.mail.factory.php

like image 41
Emyr Avatar answered Jan 24 '23 07:01

Emyr