Monday, 10 June 2013

How to send an email in PHP?


To send an email in php you can use the in-built function provided by php.

mail($tomail,$subjectofmail,$mailbody,$mailheaders);

This is the syntax of  mail function in php.

For above function to work, there should be up and running mail server available on the web server.

There are below settings in php.ini that must be set properly for mail system to work.
  1. SMTP - name of mail server - Generally Localhost
  2. smtp_port -  Generally 25 .
  3. sendmail_from - from address of the mail

If you do not know configuration of your mail server, you must contact your server administrator to get it.

Apart from above mail function, You can use methods provided in popular php frameworks like cakephp, codeigniter etc.

No comments:

Post a Comment