Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $from = 'From: yoursite.com';
- $to = 'contact@yoursite.com';
- $subject = 'Customer Inquiry';
- $body = "From: $namen E-Mail: $emailn Message:n $message";
- if ($_POST['submit']) {
- if (mail ($to, $subject, $body, $from)) {
- echo '<p>Your message has been sent!</p>';
- } else {
- echo '<p>Something went wrong, go back and try again!</p>';
- }
- }
- ?>
- error_reporting(-1);
- ini_set('display_errors', 'On');
- set_error_handler("var_dump");
- $headers = array("From: from@example.com",
- "Reply-To: replyto@example.com",
- "X-Mailer: PHP/" . PHP_VERSION
- );
- $headers = implode("rn", $headers);
- mail($to, $subject, $message, $headers);
- $headers = array("From from@example.com", // missing colon
- "Reply To: replyto@example.com", // missing hyphen
- "X-Mailer: "PHP"/" . PHP_VERSION // bad quotes
- );
- $to = 'user@example.com';
- // other variables ....
- mail($recipient, $subject, $message, $headers); // $recipient should be $to
- mail('user@example.com', $subject, $message, $headers);
- ini_set("mail.log", "/tmp/mail.log");
- ini_set("mail.add_x_header", TRUE);
- $header = "From: noreply@example.comrn";
- $header.= "MIME-Version: 1.0rn";
- $header.= "Content-Type: text/html; charset=ISO-8859-1rn";
- $header.= "X-Priority: 1rn";
- $status = mail($to, $subject, $message, $header);
- if($status)
- {
- echo '<p>Your mail has been sent!</p>';
- } else {
- echo '<p>Something went wrong, Please try again!</p>';
- }
- function send_mail($email, $recipient_name, $message='')
- {
- require("phpmailer/class.phpmailer.php");
- $mail = new PHPMailer();
- $mail->CharSet="utf-8";
- $mail->IsSMTP(); // set mailer to use SMTP
- $mail->Host = "mail.example.com"; // specify main and backup server
- $mail->SMTPAuth = true; // turn on SMTP authentication
- $mail->Username = "myusername"; // SMTP username
- $mail->Password = "p@ssw0rd"; // SMTP password
- $mail->From = "me@walalang.com";
- $mail->FromName = "System-Ad";
- $mail->AddAddress($email, $recipient_name);
- $mail->WordWrap = 50; // set word wrap to 50 characters
- $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
- $mail->Subject = "This is a Sampleenter code here Email";
- $mail->Body = $message;
- $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
- $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
- $mail->addAttachment('files/file.xlsx');
- if(!$mail->Send())
- {
- echo "Message could not be sent. <p>";
- echo "Mailer Error: " . $mail->ErrorInfo;
- exit;
- }
- echo "Message has been sent";
- }
- $headers = "MIME-Version: 1.0" . "rn";
- $headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
- $headers .= "From: ". $from. "rn";
- $headers .= "Reply-To: ". $from. "rn";
- $headers .= "X-Mailer: PHP/" . phpversion();
- $headers .= "X-Priority: 1" . "rn";
- mail('email@gmail.com', $subject, $message, $headers)
- <?php
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $from = 'From: yoursite.com';
- $to = 'contact@yoursite.com';
- $subject = 'Customer Inquiry';
- $body = "From: $namen E-Mail: $emailn Message:n $message";
- $headers .= "MIME-Version: 1.0rn";
- $headers .= "Content-type: text/htmlrn";
- $headers .= 'From: from@example.com' . "rn" .
- 'Reply-To: reply@example.com' . "rn" .
- 'X-Mailer: PHP/' . phpversion();
- mail($to, $subject, $message, $headers);
- <?php
- $SmtpServer="smtp.*.*";
- $SmtpPort="2525"; //default
- $SmtpUser="***";
- $SmtpPass="***";
- ?>
- <?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 ()
- {
- $newLine = "rn";
- $headers = "MIME-Version: 1.0" . $newLine;
- $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
- 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.">rn".$headers."nnSubject:".$this->subject."rnrnrn".$this->body."rn.rn");
- $talk["send"]=fgets($SMTPIN,256);
- //CLOSE CONNECTION AND EXIT ...
- fputs ($SMTPIN, "QUITrn");
- fclose($SMTPIN);
- //
- }
- return $talk;
- }
- }
- ?>
- <?php
- include('SMTPconfig.php');
- include('SMTPmail.php');
- if($_SERVER["REQUEST_METHOD"] == "POST")
- {
- $to = "";
- $from = $_POST['email'];
- $subject = "Enquiry";
- $body = $_POST['name'].'</br>'.$_POST['companyName'].'</br>'.$_POST['tel'].'</br>'.'<hr />'.$_POST['message'];
- $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
- $SMTPChat = $SMTPMail->SendMail();
- }
- ?>
- $config = Array(
- 'protocol' => 'smtp',
- 'smtp_host' => 'mail.domain.com', //your smtp host
- 'smtp_port' => 26, //default port smtp
- 'smtp_user' => 'name@domain.com',
- 'smtp_pass' => 'password',
- 'mailtype' => 'html',
- 'charset' => 'iso-8859-1',
- 'wordwrap' => TRUE
- );
- $message = 'Your msg';
- $this->load->library('email', $config);
- $this->email->from('name@domain.com', 'Title');
- $this->email->to('emaildestination@domain.com');
- $this->email->subject('Header');
- $this->email->message($message);
- if($this->email->send())
- {
- //conditional true
- }
- <?php
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $from = 'From: yoursite.com';
- $to = 'contact@yoursite.com';
- $subject = 'Customer Inquiry';
- $body = "From:" .$name."rn E-Mail:" .$email."rn Message:rn" .$message;
- if (isset($_POST['submit']))
- {
- if (mail ($to, $subject, $body, $from))
- {
- echo '<p>Your message has been sent!</p>';
- }
- else
- {
- echo '<p>Something went wrong, go back and try again!</p>';
- }
- }
- ?>
- $name = $_POST['name'];
- $email = $_POST['email'];
- $reciver = '/* Reciver Email address */';
- if (filter_var($reciver, FILTER_VALIDATE_EMAIL)) {
- $subject = $name;
- // To send HTML mail, the Content-type header must be set.
- $headers = 'MIME-Version: 1.0' . "rn";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
- $headers .= 'From:' . $email. "rn"; // Sender's Email
- //$headers .= 'Cc:' . $email. "rn"; // Carbon copy to Sender
- $template = '<div style="padding:50px; color:white;">Hello ,<br/>'
- . '<br/><br/>'
- . 'Name:' .$name.'<br/>'
- . 'Email:' .$email.'<br/>'
- . '<br/>'
- . '</div>';
- $sendmessage = "<div style="background-color:#7E7E7E; color:white;">" . $template . "</div>";
- // Message lines should not exceed 70 characters (PHP rule), so wrap it.
- $sendmessage = wordwrap($sendmessage, 70);
- // Send mail by PHP Mail Function.
- mail($reciver, $subject, $sendmessage, $headers);
- echo "Your Query has been received, We will contact you soon.";
- } else {
- echo "<span>* invalid email *</span>";
- }
- $mail->SMTPDebug = 2;
- <?php
- $to = "somebody@example.com, somebodyelse@example.com";
- $subject = "HTML email";
- $message = "
- <html>
- <head>
- <title>HTML email</title>
- </head>
- <body>
- <p>This email contains HTML Tags!</p>
- <table>
- <tr>
- <th>Firstname</th>
- <th>Lastname</th>
- </tr>
- <tr>
- <td>John</td>
- <td>Doe</td>
- </tr>
- </table>
- </body>
- </html>";
- // Always set content-type when sending HTML email
- $headers = "MIME-Version: 1.0" . "rn";
- $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
- // More headers
- $headers .= 'From: <webmaster@example.com>' . "rn";
- $headers .= 'Cc: myboss@example.com' . "rn";
- mail($to,$subject,$message,$headers);
- ?>
- if ($_POST['submit']) {
- $success= mail($to, $subject, $body, $from);
- if($success)
- {
- echo '
- <p>Your message has been sent!</p>
- ';
- } else {
- echo '
- <p>Something went wrong, go back and try again!</p>
- ';
- }
- }
- require 'mail/swift_required.php';
- $message = Swift_Message::newInstance()
- // The subject of your email
- ->setSubject('Jane Doe sends you a message')
- // The from address(es)
- ->setFrom(array('jane.doe@gmail.com' => 'Jane Doe'))
- // The to address(es)
- ->setTo(array('frank.stevens@gmail.com' => 'Frank Stevens'))
- // Here, you put the content of your email
- ->setBody('<h3>New message</h3><p>Here goes the rest of my message</p>', 'text/html');
- if (Swift_Mailer::newInstance(Swift_MailTransport::newInstance())->send($message)) {
- echo json_encode([
- "status" => "OK",
- "message" => 'Your message has been sent!'
- ], JSON_PRETTY_PRINT);
- } else {
- echo json_encode([
- "status" => "error",
- "message" => 'Oops! Something went wrong!'
- ], JSON_PRETTY_PRINT);
- }
- <?php
- error_reporting(0);
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $from = 'From: yoursite.com';
- $to = 'contact@yoursite.com';
- $subject = 'Customer Inquiry';
- $body = "From: $namen E-Mail: $emailn Message:n $message";
- if ($_POST['submit']){
- if (!(empty($_POST['name']))) {
- if (!(empty($_POST['email']))){
- if (!(empty($_POST['message']))){
- mail ($to, $subject, $body, $from);
- echo '<p>Your message has been sent!</p>';
- }else{
- echo '<p>Fill your message please.</p>';}
- }else {
- echo '<p>Fill your email please.</p>';}
- }else{
- echo '<p>Fill your name please.</p>';}
- }else{
- echo '<p>Fill the form.</p>';}
- ?>
- <html>
- <form method="post" action="?">
- <table>
- <tr><td>Name</td><td><input type='text' name='name' id='name'/></td></tr>
- <tr><td>Email</td><td><input type='text' name='email' id='email'/></td></tr>
- <tr><td>Message</td><td><input type='text' name='message' id='message'/></td></tr>
- <tr><td></td><td><input type='submit' name='submit' id='submit'/></td></tr>
- </table>
- </form>
- </html>
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $from = 'From: yoursite.com';
- $to = 'contact@yoursite.com';
- $subject = 'Customer Inquiry';
- $body = "From: $namen E-Mail: $emailn Message:n $message";
- <?php
- $to = 'nobody@example.com';
- $subject = 'the subject';
- $message = 'hello';
- $headers = 'From: webmaster@example.com' . "rn" .
- 'Reply-To: webmaster@example.com' . "rn" .
- 'X-Mailer: PHP/' . phpversion();
- mail($to, $subject, $message, $headers);
- ?>
- From: myapp@example.com
- To: mymail@example.com
- Subject: Test mail via sendmail.
- Text body.
- root=mymail@example.com
- mailhub=smtp.yandex.ru:465
- FromLineOverride=YES
- UseTLS=YES
- AuthUser=abcde@yandex.ru
- AuthPass=password
- require_once('../PHPMailer/class.phpmailer.php');
- $mail = new PHPMailer();
- $mail->From = '';
- $mail->FromName = '';
- $mail->Subject = '';
- $MESSAGE_BODY = "Name: ".$name." "."rn";
- $MESSAGE_BODY .= "Email: ".$email." "."rn";
- $MESSAGE_BODY .= "Contact No.: ".$cno." "."rn";
- $MESSAGE_BODY .= "Message: ".$message." "."rn";
- $mail->Body = $MESSAGE_BODY;
- $mail->AddAddress( '' );
- if ($mail->Send())
- {
- echo "Mail Sent";
- }
- else
- {
- echo "Could not send mail";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement