PHP code to send an email

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
New php-forum User
New php-forum User
Posts: 137
Joined: Wed Aug 31, 2011 3:55 am
Location: USA

Tue Sep 27, 2011 1:36 pm

well I don't know why your using the mail function like that and since I have no knowledge on that. This is better. Just use the PHP mail function.

Code: Select all

// Mine

    //change this to your email.
    $to = "";
    $from = "";
    $subject = "Hello! This is HTML email";

    //begin of HTML message
    $message = "<html>
  <body bgcolor=\"#DCEEFC\">
        <b>Looool!!! I am reciving HTML email......</b> <br>
        <font color=\"red\">Thanks Mohammed!</font> <br>
        <a href=\"\">*</a>
      <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine
   //end of message

    // To send the HTML mail we need to set the Content-type header.
    $headers = "MIME-Version: 1.0rn";
    $headers .= "Content-type: text/html; charset=iso-8859-1rn";
    $headers  .= "From: $from\r\n";
    //options to send to cc+bcc
    //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
    //$headers .= "Bcc: [email]email@maaking.cXom[/email]";
    // now lets send the email.
    mail($to, $subject, $message, $headers);

    echo "Message has been sent....!";

User avatar
New php-forum User
New php-forum User
Posts: 35
Joined: Thu Oct 27, 2011 1:24 pm

Thu Oct 27, 2011 3:29 pm


Something with ur $smtp, not really sure though. I would suggest you take a look at this post, and see how easy I have done it.

Just take a deep breath, and start all over, step by step, and you'll get it.

Hope it helps.

Post Reply