You are on page 1of 5

Emailing With PHP

What is Email?
  E­mail, short for electronic mail and often abbreviated to e­mail, 
email or simply mail, is a store and forward method of composing, 
sending, receiving and storing messages over electronic communication 
systems.

History of Email
  1. MIT first demonstrated the Compatible Time­Sharing System (CTSS) 
in 1961.It allowed multiple users to log into the IBM 7094 from remote 
dial­up terminals, and to store files online on disk. This new ability 
encouraged users to share information in new ways. E­mail started in 
1965 as a way for multiple users of a time­sharing mainframe computer 
to communicate.
     Note : Time­Sharing refers to sharing a computing resource among 
many users by multitasking.

 2. In the early 1970's, Ray Tomlinson was working on a small team 
developing the TENEX operating system,with local email programs called 
SNDMSG and READMAIL.

 3.In late 1971, Tomlinson developed the first ARPANET email 
application when he updated SNDMSG by adding a program called CPYNET 
capable of copying files over the network, and informed his colleagues 
by sending them an email using the new program with instructions on how 
to use it. 

  4. Network capable email was developed for the ARPANET (The ARPANET 
(Advanced Research Projects Agency Network) developed by DARPA (Defense 
Advanced Research Projects Agency) of the United States Department of 
Defense, was the world's first operational packet switching network, 
and the predecessor of the global Internet)

 5. SMTP (standard for e­mail transmissions across the Internet) was 
published as RFC 821 in August 1982, also by Jonathan Postel
 6.Allman developed sendmail program, which was distributed with BSD 
Unix, and has gone on to become the the most commonly used SMTP server 
on the Internet.

Applications or Use 
 
   1.The  Hotmail service was founded by Sabeer Bhatia and Jack Smith , 
and was one of the first webmail services on the Internet. It was 
commercially launched on July 4, 1996, American Independence Day.
   2. It was sold at 1997 to Microsoft for a reported $400 million, and 
it joined the MSN group of services

   3.Yahoo! Mail (Started at 1996) is a Web­based email (webmail) 
service from Yahoo!. It is the most used e­mail on the Internet, 
serving over 260 million users.  
   
   4. Gmail, officially Google Mail  is a free Web­based email 
(webmail), POP3[1] and IMAP[2] e­mail service provided by Google. On 
April 1, 2004 the product began as an invitation­only beta release. On 
February 7, 2007 the beta version was opened to the general public.
Technology Used In Email

Technology Used In Email
   The format of Internet e­mail messages is defined in RFC 2822 and a 
series of RFCs, RFC 2045 through RFC 2049, collectively called 
Multipurpose Internet Mail Extensions (MIME).

Internet e­mail messages consist of two major sections:

    * Header — Structured into fields such as summary, sender, 
receiver, and other information about the e­mail
    * Body — The message itself as unstructured text; sometimes 
containing a signature block at the end

  The header is separated from the body by a blank line.

Header

The message header consists of fields, usually including at least the 
following:

    * From: The e­mail address, and optionally the name of the sender
    * To: The e­mail address[es], and optionally name[s] of the
      message's recipient[s]
    * Subject: A brief summary of the contents of the message
    * Date: The local time and date when the message was written

Other common header fields include (see RFC 4021 or RFC 2076 for more):
    * Cc: carbon copy
    * Bcc: Blind Carbon Copy
    * Received: Tracking information generated by mail servers that
      have previously handled a message
    * Content­Type: Information about how the message has to be
      displayed, usually a MIME type
    * Reply­To: Address that should be used to reply to the sender.
    * References: Message­ID of the message that this is a reply to,
      and the message­id of this message, etc.
    * In­Reply­To: Message­ID of the message that this is a reply to.
    * X­Face: Small icon.

Many e­mail clients present "Bcc" (Blind carbon copy, recipients not 
visible in the "To" field) as a header field. Different protocols are 
used to deal with the "Bcc" field; at times the entire field is 
removed, whereas other times the field remains but the addresses 
therein are removed. Addresses added as "Bcc" are only added to the 
SMTP delivery list, and do not get included in the message data.
Body

Content encoding

     * E­mail was originally designed for 7­bit ASCII. Much e­mail
       software is 8­bit clean but must assume it will be communicating
       with 7­bit servers and mail readers. 

Plain Text and HTML

     * Both plain text and HTML are used to convey e­mail. Advantages
       of HTML include the ability to include inline links and images, 
  set apart previous messages in block quotes, wrap naturally on 
  any display, use emphasis such as underlines and italics, and 
  change font styles. 

Example
Delivered­To: anthoniraja@gmail.com
Received: by 10.140.203.16 with HTTP; Thu, 20 Mar 2008 00:52:52 
­0700 (PDT)
Message­ID: 
<a235b2140803200052x361499a0h323e8ac1d0d1f19f@mail.gmail.com>
Date: Thu, 20 Mar 2008 13:22:52 +0530
From: "xavier suresh" <pxaviersuresh@gmail.com>
To: "Anthoni raj" <anthoniraja@gmail.com>
Subject: asking iedas
MIME­Version: 1.0

dear friend
happy newyear if you have any  picture  please send me today

Client­Server Technology

     * Messages are exchanged between hosts using the Simple Mail 
Transfer Protocol with software programs called mail transport agents. 
Users can download their messages from servers with standard protocols 
such as the POP or IMAP protocols, or, as is more likely in a large 
corporate environment, with a proprietary protocol specific to Lotus 
Notes or Microsoft Exchange Servers.

     * Mail can be stored either on the client, on the server side, or 
in both places. Standard formats for mailboxes include Maildir and 
mbox. Several prominent e­mail clients use their own proprietary format 
and require conversion software to transfer e­mail between them.

     * When a message cannot be delivered, the recipient MTA must send 
a bounce message back to the sender, indicating the problem.
Filename extensions

 e­mail clients save individual messages as separate files, or allow 
users to do so. Different applications save e­mail files with different 
filename extensions.

.eml
    This is the default e­mail extension for Mozilla Thunderbird and 
Windows Mail. It is used by Microsoft Outlook Express.

.emlx
    Used by Apple Mail.

.msg
    Used by Microsoft Office Outlook. 

Sendmail Configuration in php.ini file

# vim /opt/lampstack/php/etc/php.ini 
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail 
­t ­i").
 sendmail_path = sendmain ­t ­i

; Force the addition of the specified parameters to be passed as extra 
parameters
; to the sendmail binary. These parameters will always replace the 
value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

Simple Example

<?php
$to      = 'amalantonyraj@yahoo.co.in';
$subject = 'From PHP';
$message = 'Test';

if(mail($to, $subject, $message))  {
  echo "Mail has been sent succesfully";
 }
 else  {
  echo "Server error";
 }
?>
Mail Function in PHP
 Syntax
  mail — Send mail
  
 Description
  bool mail ( string $to , string $subject , string $message [, string 
$additional_headers [, string $additional_parameters ]] )

Parameters

to

    Receiver, or receivers of the mail.

    The formatting of this string must comply with » RFC 2822. Some 
examples are:

        * user@example.com
        * user@example.com, anotheruser@example.com
        * User <user@example.com>
        * User <user@example.com>, Another User 
<anotheruser@example.com>

subject

    Subject of the email to be sent.
   
Caution

    This must not contain any newline characters, or the mail may not 
be sent properly.

message

    Message to be sent ­   Each line should be separated with a LF 
(\n). Lines should not be larger than 70 characters.
 

additional_headers (optional)

String to be inserted at the end of the email header. 
This is typically used to add extra headers (From, Cc, and Bcc). 
Multiple extra headers should be separated with a CRLF (\r\n). 

additional_parameters (optional)

sending mail using the sendmail_path configuration setting. For 
example, this can be used to set the envelope sender address when using 
sendmail with the ­f sendmail option.

You might also like