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
- );
- $headers = array("From: $_POST[contactform_sender_email]"); // No!
- $to = 'user@example.com';
- // other variables ....
- mail($recipient, $subject, $message, $headers); // $recipient should be $to
- mail('user@example.com', $subject, $message, $headers);
- <form action="send_email.php" method="POST">
- 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";
- }
- <?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);
- $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
- $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();
- }
- ?>
- $mail->SMTPDebug = 2;
- <?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>';
- }
- }
- ?>
- $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
- }
- $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>";
- }
- <?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>
- ';
- }
- }
- $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";
- 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);
- }
- sudo apt-get install sendmail
- require_once 'PHPMailer/PHPMailer.php';
- require_once '/servicios/PHPMailer/SMTP.php';
- require_once '/servicios/PHPMailer/Exception.php';
- $mail = new PHPMailerPHPMailerPHPMailer(true);
- try {
- //Server settings
- $mail->SMTPDebug = 0;
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'correo@gmail.com';
- $mail->Password = 'contrasenia';
- $mail->SMTPSecure = 'ssl';
- $mail->Port = 465;
- //Recipients
- $mail->setFrom('correo@gmail.com', 'my name');
- $mail->addAddress('destination@correo.com');
- //Attachments
- $mail->addAttachment('optional file'); // Add files, is optional
- //Content
- $mail->isHTML(true);// Set email format to HTML
- $mail->Subject = utf8_decode("subject");
- $mail->Body = utf8_decode("mail content");
- $mail->AltBody = '';
- $mail->send();
- }
- catch (Exception $e){
- $error = $mail->ErrorInfo;
- }
- 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
- <?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);
- ?>
- include "libmail.php";
- $m = new Mail(); // create the mail
- $m->From( $_POST['form'] );
- $m->To( $_POST['to'] );
- $m->Subject( $_POST['subject'] );
- $m->Body( $_POST['body'] );
- $m->Cc( $_POST['cc']);
- $m->Priority(4);
- // attach a file of type image/gif to be displayed in the message if possible
- $m->Attach( "/home/leo/toto.gif", "image/gif", "inline" );
- $m->Send(); // send the mail
- echo "Mail was sent:"
- echo $m->Get(); // show the mail source
- [mail function]
- sendmail_path=/usr/sbin/sendmail -t -i
- ; (Other directives are mostly windows)
- su - # Install as user 'root'
- dpkg --list # Is install necessary?
- apt-get install sendmail sendmail-cf m4 # Note multiple package selection
- sendmailconfig # Respond all 'Y' for new install
- which sendmail # /usr/sbin/sendmail
- which sendmailconfig # /usr/sbin/sendmailconfig
- man sendmail # Documentation
- systemctl restart sendmail # As and when required
- echo "Subject: sendmail test" | sendmail -v <yourEmail>@gmail.com
- error_reporting(E_ALL);
- <?php
- use PHPMailerPHPMailerPHPMailer;
- require 'PHPMailer.php';
- require 'SMTP.php';
- require 'Exception.php';
- $name=$_POST['name'];
- $mailid=$_POST['mail'];
- $mail = new PHPMailer;
- $mail->IsSMTP();
- $mail->SMTPDebug = 0; // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
- $mail->Port = 587; // Set the SMTP port
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'someone@gmail.com'; // SMTP username
- $mail->Password = 'password'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
- $mail->From = 'someone@gmail.com';
- $mail->FromName = 'name';
- $mail->AddAddress($mailid,$name); // Name is optional
- $mail->IsHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'Here is your message' ;
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- if(!$mail->Send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- exit;
- }
- echo 'Message has been sent';
- ?>
- <?php
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $header ="
- Content-Type: text/html; charset=UTF-8rn
- MIME-Version: 1.0rn
- From: "$name" <$email>rn
- Reply-To: no-reply@yoursite.comrn
- X-Mailer: yoursite.com mailerrn
- ";
- $to = '"Contact" <contact@yoursite.com>';
- $subject = 'Customer Inquiry';
- $body =<<<EOB
- <!DOCTYPE html>
- <html>
- <body>
- $message
- </body>
- </html>
- EOB;
- if ($_POST['submit']) {
- if (mail ($to, $subject, $body, $header) !== false) {
- echo '<p>Your message has been sent!</p>';
- } else {
- echo '<p>Something went wrong, go back and try again!</p>';
- }
- }
- ?>
- <?php
- require_once ("PHPMailer/PHPMailerAutoload.php");
- $error = array();
- //var_dump($_POST);
- $message = $_POST['a'] . '<br>';
- $message.= $_POST['b'] . '<br>';
- $message.= $_POST['c'] . '<br>';
- $message.= $_POST['d'] . '<br>';
- $message.= $_POST['e'] . '<br>';
- $message.= $_POST['f'] . '<br>';
- $message.= $_POST['g'] . '<br>';
- $message.= $_POST['h'] . '<br>';
- $message.= $_POST['i'] . '<br>';
- $message.= $_POST['j'] . '<br>';
- $message.= $_POST['k'] . '<br>';
- $subject = "Visitor Query";
- $from = "******@******.com"; // example a@b.com
- $password = '******';
- $mail = new PHPMailer();
- $body = $message;
- $mail->IsSMTP();
- $mail->SMTPAuth = true; // turn on SMTP authentication
- $mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
- $mail->SMTPDebug = 0;
- //$mail->Host = 'mail.******.com'; // sets SMTP server
- $mail->Host = 'mail.******.com'; // sets SMTP server
- $mail->SMTPSecure = 'ssl';
- $mail->Port = 465;
- //$mail->Port = 25;
- $mail->Username = $from; // SMTP username
- $mail->Password = $password; // SMTP password
- $mail->AddAddress ( "******@gmail.com" );
- $mail->AddReplyTo ( "******@gmail.com", "Team");
- $mail->Subject = $subject;
- $mail->Body = $message;
- $mail->From = $from;
- $mail->FromName = "Visitor's Query";
- $mail->ContentType = "text/html";
- if (count($error == 0)) {
- $mail->Send();
- // echo "_________________wait_______for_______ our _______ reply !";
- } else {
- echo $error; // show error messages
- //echo $result;
- }
- //header("location: index.php");
- ?>
Add Comment
Please, Sign In to add comment