How to Send Email Using PHP

Oct-25-2014 in PHP No comments

Today, Sending email is often used on a web page, so today this article will explain to you how to send mail on your website.

To send email using php script you can use Mail Function or SMTP:

how to send email using php

Send Mail using php mail function:

This method is often used for the Host support the function Mail () to know your host supports it or not you can see in phpinfo.

$to: Recipient email address .
$subject: Title email.
$message: the message body.
$additional_headers: This is Optional. Additional headers From, Cc, and Bcc.
$additional_parameters: This is Optional. Additional attributes accessories for email.

Mail() function will returns TRUE If your e-mail was sent successfully and If you send email failure this fuction returns FALSE.

Example: Send Mail using PHP

In this method you will find three types send email:

  1. Send text from email:

    send email as above

  2. Send HTML emails:

    you need to add additional header Content-type: multipart/alternative in $header.

  3. Send Email with attachment:

    you need to use a header Content-type: multipart/mixed MIME type in $header.

Send Mail using smtp server:

This methods to send email is usually integrated to the open source like WordPress, Joomla, vBulletin etc ….

To use this method you need to download the library include of two class: “class.phpmailer.php” and “class.smtp.php”

Details you can see in the code above script php.

Right now! you can create form send mail on your website!

Add Your Comment