Sending Email in PHP (Example)

person Jason Huangfolder_openCode, HOW-TO, PHPlocal_offer, access_time September 23, 2009

If you configured the SMTP hosts in php.ini, you can easily send email via PHP.
Simply use the mail() function in PHP and put in the parameters for email to, subject, email, and header information.


//send email to
$email_to = "somebody@somewhere.com";
//subject of email
$email_subject = "Test Subject of the email";
//Email is from
$header="from: test@monkeycancode.com";
 
//body of the email message, simply make a string.
$message="Hello \r\n";
$message.="This is test\r\n";
$message.="Test again ";
 
/* Send email using the mail function in PHP */
/* the function return true if email is sent successfully. */
$sentmail = mail($email_to,$email_subject,$message,$header);
 
// if your email succesfully sent
if($sentmail)
{
	echo "Email Has Been Sent .";
}
else
{
	echo "Cannot Send Email ";
}

Download the source code here: test_email.php

Comments

  1. i need full code for sending the email from the starting and also need full description of this document.

  2. Without even considering the bulk of the project and
    the tasks and responsibilities, there’s a risk of double hiring.
    CPA affiliate marketing is comparable to affiliate marketing
    sites, but, rather than promoting one or two
    products, and selling them, you can pick from your CPA
    network’s offers, (literally hundreds of delivers, including numerous distinct and popular niches) and
    you can be able to get paid to your lead generation efforts as well
    as for the sales. Many affiliates will use article marketing and create
    a resource box that leads back to their own website or CPA landing page.

    Feel free to visit my web page – cpas in fort lauderdale fl

  3. By way of example, an Ophthalmologist should employ staffs who may help
    you pick a qualified frames to your eyes, as the doctor
    is attending another patient. Daily Contact Lenses – This is the most popular
    type of lens amongst sufferers of a vision problem and frequently recommended by
    eye care specialist for first time users because of their
    convenience. If you can’t stand the thickness or
    aroma choose another type that suits you better.

    Feel free to visit my site :: how much is eye exam brooklyn

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>