The document discusses sending emails using PHP. It provides the syntax for PHP's mail() function, including required and optional parameters. It then gives an example of sending a simple text email. It also demonstrates how to create an HTML form that sends email input to a specified address. Finally, it provides an overview of different types of web services (SOAP, XML-RPC, REST), their advantages and disadvantages, and reasons for using web services.
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
Sending mail,web services
1. Akshara Dave Page 1
SVIIT
Sending mail using PHP
PHP allows you to send e-mails directly from a script using mail() function.
Syntax:
Mail (to, subject, message, headers, parameters)
Parameter Description
To Required. Specifies the receiver/receivers of the email
subject Required. Specifies the subject of the email. Note: This parameter
cannot contain any newline characters
message Required. Defines the message to be sent. Each line should be
separated with a LF (n). Lines should not exceed 70 characters
headers Optional. Specifies additional headers, like From, Cc, and Bcc. The
additional headers should be separated with a CRLF (rn)
parameters Optional. Specifies an additional parameter to the sendmail program
Send a simple mail:
<?php
$to = "abc@yahoo.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = ”xyz@gmail.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
PHP Mail form:
With PHP, you can create a feedback-form on your website. The example below sends a text message
to a specified e-mail address:
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("someone@example.com", $subject,
$message, "From:" . $email);
echo "Thank you for using our mail form";
}
else
2. Akshara Dave Page 2
SVIIT
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text'><br>
Subject: <input name='subject' type='text'><br>
Message:<br>
<textarea name='message' rows='15' cols='40'>
</textarea><br>
<input type='submit'>
</form>";
}
?>
</body>
</html>
This is how the example above works:
First, check if the email input field is filled out
If it is not set (like when the page is first visited); output the HTML form
If it is set (after the form is filled out); send the email from the form
When submit is pressed after the form is filled out, the page reloads, sees that the email input
is set, and sends the email
3. Akshara Dave Page 3
SVIIT
Web Services:
A “web service” is a network accessible interface to application functionality built using XML and
usually HTTP.
Three forms of Web services:
SOAP
XML-RPC
REST
SOAP
Formerly known as Simple Object Access Protocol
Uses XML, but it is not needed
One just call functions and manipulate arrays.
A few PHP implementations: PEAR::SOAP, PHP-SOAP, NuSOAP
SOAP is most complicated and has interoperability problems but large vendors such as
Microsoft, and IBM have thrown support behind it.
XML-RPC
XML is Remote procedural Call
Advantage: Similar to SOAP but less complex
Disadvantage: SOAP has better buzzword compliance
XML-RPC offers a nice blend of power and simplicity but lacks big vendor support.
REST
Representational State Transfer(Roy fielding)
Make URI request using existing HTTP methods: GET/ POST/ PUT/ DELETE
Data returned as XML and not needed.
Many ways to parse XML: SAX/ DOM/ XSLT/ SimpleXML
REST is most lightweight and easy to use but offers the least functionality
REST vs. SOAP
Both REST and SOAP is widely adopted techniques for building distributed systems. REST is an
architectural style for implementing systems on top of HTTP infrastructure. A large number of
specifications have been developed on top of SOAP and there are large number of SOAP stacks both
open source and proprietary out there implementing large part of stack
Both these techniques have their advantages and drawbacks. Here are few of the advantages and
disadvantages of each paradigm.
4. Akshara Dave Page 4
SVIIT
REST advantage:
Based on few simple principles which are already in wide adoption on the web itself
Can be implemented very quickely
Ideal for providing simple API’s to the users.(E.G. whether services, flicker, yahoo REST
services)
Amount of learning required to get started is minimum in comparison to SOAP
Has a very large following amount the scripting community
REST Disadvantage:
IF the system is a very large one, then designing based on REST could become a very complex
task
Implementing security on a REST system is one major issue. Although HTTPS, and HTTP
authentication can be used, they only provide transport level security.
SOAP advantage:
Well designed
Has been widely adopted in industry
Large number of SOAP stacks available to choose from.
Has support for both transport level and message level security which is a big advantage over
REST
Supports multiple protocol binding (not just HTTP)
Ideal for implementing complex enterprise systems since the SOAP stacks cater for security,
reliability, transactions etc.
SOAP Disadvantage:
Complex in comparison to REST
Big learning curve required
Difficult to debug a complex system
One great thing about using WSF/ PHP is that it can support both of these techniques simultaneously.
Reasons to use Web services:
Web services operate on a service based model architecture. This the most compelling reason why we
use web services.
Second reason for using is that web services allow us to communicate among all different entities
without affecting their existence.
This forms the third reason for using a web service is that it is written separately from the application
logic.
The fourth reason why we use web service is that they improve the information flow between
applications.
The fifth reason why we use web service is that, web services, use text based protocol that all
applications can understand.