Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Send email in PHP with HTML Template

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 608
    Comment on it

    Hi Reader's,

    Welcome to FindNerd, today we are going to discuss how to send email in PHP.

    In web applications sending email is a very important feature. 

    PHP provides a built-in mail() function for creating and sending emails to one or more recipients. mail() function is very useful and simple to implement in your website or application.

      Syntax of mail() function
       mail(recipient_email, subject, message, headers, parameters).

    Description of parameter :

    recipient_email :This is required parameter and it is a recipient's email address.You can add multiple email addresses using comma(,).

    subject :Is is also a required parameter and this is subject of email. This parameter cannot contain any newline characters.

    message :This parameter is used to set messages to be sent.Each line should be separated with a LF (\n).This is also required parameter.

    headers : Additional parameters (Optional) and specifies additional headers, like From, Cc, and Bcc..

    parameters : Additional parameters and specifies an additional parameter for sending the sendmail.(Optional)

    you can see below example.

        //write here recipient emaol address
        $recipient = '';
        $subject = 'Test for HTML email';
        //Content-type always be set
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
        $headers = "From:\r\nReply-To:";
        $message = '<html><body>';
        $message .= '<p style="color:#000;font-size:12px;">This is testing eamil.</p>';
        $message .= '</body></html>';
       //use mail() here
        if(mail($recipient, $subject, $message, $headers)){
        echo  "Success ! Email send successfully.";
        } else{
        echo "Error ! Email can not send.";


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: