Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('SMTPconfig.php');
- include('SMTPClass.php');
- if($_SERVER["REQUEST_METHOD"] == "POST")
- {
- $to = $_POST['to'];
- $from = $_POST['from'];
- $subject = $_POST['sub'];
- $body = $_POST['message'];
- $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass,
- $from, $to, $subject, $body);
- $SMTPChat = $SMTPMail->SendMail();
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>form</title>
- </head>
- <body>
- <form method="post" action="">
- <table width="500px">
- <tr><td width="20%">To : </td>
- <td ><input type="text" name="to" /></td></tr>
- <tr><td>From :</td><td><input type='text' name="from" /></td></tr>
- <tr><td>Subject :</td><td><input type='text' name="sub" /></td></tr>
- <tr><td>Message :</td><td><textarea name="message"></textarea></td></tr>
- <tr><td></td><td><input type="submit" value=" Send " /></td></tr>
- </table>
- </form>
- </body>
- </html>
- <?php
- class SMTPClient
- {
- function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from,
- $to, $subject, $body)
- {
- $this->SmtpServer = $SmtpServer;
- $this->SmtpUser = base64_encode ($SmtpUser);
- $this->SmtpPass = base64_encode ($SmtpPass);
- $this->from = $from;
- $this->to = $to;
- $this->subject = $subject;
- $this->body = $body;
- if ($SmtpPort == "")
- {
- $this->PortSMTP = 25;
- }else{
- $this->PortSMTP = $SmtpPort;
- }
- }
- function SendMail ()
- {
- if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
- {
- fputs ($SMTPIN, "EHLO ".$HTTP_HOST."rn");
- $talk["hello"] = fgets ( $SMTPIN, 1024 );
- fputs($SMTPIN, "auth loginrn");
- $talk["res"]=fgets($SMTPIN,1024);
- fputs($SMTPIN, $this->SmtpUser."rn");
- $talk["user"]=fgets($SMTPIN,1024);
- fputs($SMTPIN, $this->SmtpPass."rn");
- $talk["pass"]=fgets($SMTPIN,256);
- fputs ($SMTPIN, "MAIL FROM: <".$this->from.">rn");
- $talk["From"] = fgets ( $SMTPIN, 1024 );
- fputs ($SMTPIN, "RCPT TO: <".$this->to.">rn");
- $talk["To"] = fgets ($SMTPIN, 1024);
- fputs($SMTPIN, "DATArn");
- $talk["data"]=fgets( $SMTPIN,1024 );
- fputs($SMTPIN, "To: <".$this->to.">rnFrom: <".$this->from.">rnSubject:".$this->subject."rnrnrn".$this->body."rn.rn");
- $talk["send"]=fgets($SMTPIN,256);
- //CLOSE CONNECTION AND EXIT ...
- fputs ($SMTPIN, "QUITrn");
- fclose($SMTPIN);
- //
- }
- return $talk;
- }
- }
- ?>
- <?php
- $SmtpServer="smtp.mail.yahoo.com";
- $SmtpPort="465";
- $SmtpUser="username@yahoo.com";
- $SmtpPass="yahoopassword";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement