Advertisement
Guest User

Untitled

a guest
Jul 15th, 2015
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1. <?php
  2. $name = $_POST['name'];
  3. $email = $_POST['email'];
  4. $message = $_POST['message'];
  5. $from = 'From: yoursite.com';
  6. $to = 'contact@yoursite.com';
  7. $subject = 'Customer Inquiry';
  8. $body = "From: $namen E-Mail: $emailn Message:n $message";
  9.  
  10. if ($_POST['submit']) {
  11. if (mail ($to, $subject, $body, $from)) {
  12. echo '<p>Your message has been sent!</p>';
  13. } else {
  14. echo '<p>Something went wrong, go back and try again!</p>';
  15. }
  16. }
  17. ?>
  18.  
  19. error_reporting(-1);
  20. ini_set('display_errors', 'On');
  21. set_error_handler("var_dump");
  22.  
  23. $headers = array("From: from@example.com",
  24. "Reply-To: replyto@example.com",
  25. "X-Mailer: PHP/" . PHP_VERSION
  26. );
  27. $headers = implode("rn", $headers);
  28. mail($to, $subject, $message, $headers);
  29.  
  30. $headers = array("From from@example.com", // missing colon
  31. "Reply To: replyto@example.com", // missing hyphen
  32. "X-Mailer: "PHP"/" . PHP_VERSION // bad quotes
  33. );
  34.  
  35. $to = 'user@example.com';
  36. // other variables ....
  37. mail($recipient, $subject, $message, $headers); // $recipient should be $to
  38.  
  39. mail('user@example.com', $subject, $message, $headers);
  40.  
  41. ini_set("mail.log", "/tmp/mail.log");
  42. ini_set("mail.add_x_header", TRUE);
  43.  
  44. <?php
  45. $name = $_POST['name'];
  46. $email = $_POST['email'];
  47. $message = $_POST['message'];
  48. $from = 'From: yoursite.com';
  49. $to = 'contact@yoursite.com';
  50. $subject = 'Customer Inquiry';
  51. $body = "From: $namen E-Mail: $emailn Message:n $message";
  52.  
  53. $headers .= "MIME-Version: 1.0rn";
  54. $headers .= "Content-type: text/htmlrn";
  55. $headers = 'From: from@example.com' . "rn" .
  56. 'Reply-To: reply@example.com' . "rn" .
  57. 'X-Mailer: PHP/' . phpversion();
  58.  
  59. mail($to, $subject, $message, $headers);
  60.  
  61. $name = $_POST['name'];
  62. $email = $_POST['email'];
  63. $reciver = '/* Reciver Email address */';
  64. if (filter_var($reciver, FILTER_VALIDATE_EMAIL)) {
  65. $subject = $name;
  66. // To send HTML mail, the Content-type header must be set.
  67. $headers = 'MIME-Version: 1.0' . "rn";
  68. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  69. $headers .= 'From:' . $email. "rn"; // Sender's Email
  70. //$headers .= 'Cc:' . $email. "rn"; // Carbon copy to Sender
  71. $template = '<div style="padding:50px; color:white;">Hello ,<br/>'
  72. . '<br/><br/>'
  73. . 'Name:' .$name.'<br/>'
  74. . 'Email:' .$email.'<br/>'
  75. . '<br/>'
  76. . '</div>';
  77. $sendmessage = "<div style="background-color:#7E7E7E; color:white;">" . $template . "</div>";
  78. // Message lines should not exceed 70 characters (PHP rule), so wrap it.
  79. $sendmessage = wordwrap($sendmessage, 70);
  80. // Send mail by PHP Mail Function.
  81. mail($reciver, $subject, $sendmessage, $headers);
  82. echo "Your Query has been received, We will contact you soon.";
  83. } else {
  84. echo "<span>* invalid email *</span>";
  85. }
  86.  
  87. function send_mail($email, $recipient_name, $message='')
  88. {
  89. require("phpmailer/class.phpmailer.php");
  90.  
  91. $mail = new PHPMailer();
  92.  
  93. $mail->CharSet="utf-8";
  94. $mail->IsSMTP(); // set mailer to use SMTP
  95. $mail->Host = "mail.example.com"; // specify main and backup server
  96. $mail->SMTPAuth = true; // turn on SMTP authentication
  97. $mail->Username = "myusername"; // SMTP username
  98. $mail->Password = "p@ssw0rd"; // SMTP password
  99.  
  100. $mail->From = "me@walalang.com";
  101. $mail->FromName = "System-Ad";
  102. $mail->AddAddress($email, $recipient_name);
  103.  
  104. $mail->WordWrap = 50; // set word wrap to 50 characters
  105. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  106.  
  107. $mail->Subject = "This is a Sampleenter code here Email";
  108. $mail->Body = $message;
  109. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  110. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  111. $mail->addAttachment('files/file.xlsx');
  112.  
  113. if(!$mail->Send())
  114. {
  115. echo "Message could not be sent. <p>";
  116. echo "Mailer Error: " . $mail->ErrorInfo;
  117. exit;
  118. }
  119.  
  120. echo "Message has been sent";
  121. }
  122.  
  123. $config = Array(
  124. 'protocol' => 'smtp',
  125. 'smtp_host' => 'mail.domain.com', //your smtp host
  126. 'smtp_port' => 26, //default port smtp
  127. 'smtp_user' => 'name@domain.com',
  128. 'smtp_pass' => 'password',
  129. 'mailtype' => 'html',
  130. 'charset' => 'iso-8859-1',
  131. 'wordwrap' => TRUE
  132. );
  133. $message = 'Your msg';
  134. $this->load->library('email', $config);
  135. $this->email->from('name@domain.com', 'Title');
  136. $this->email->to('emaildestination@domain.com');
  137. $this->email->subject('Header');
  138. $this->email->message($message);
  139.  
  140. if($this->email->send())
  141. {
  142. //conditional true
  143. }
  144.  
  145. <?php
  146. $name = $_POST['name'];
  147. $email = $_POST['email'];
  148. $message = $_POST['message'];
  149. $from = 'From: yoursite.com';
  150. $to = 'contact@yoursite.com';
  151. $subject = 'Customer Inquiry';
  152. $body = "From:" .$name."rn E-Mail:" .$email."rn Message:rn" .$message;
  153.  
  154. if (isset($_POST['submit']))
  155. {
  156. if (mail ($to, $subject, $body, $from))
  157. {
  158. echo '<p>Your message has been sent!</p>';
  159. }
  160. else
  161. {
  162. echo '<p>Something went wrong, go back and try again!</p>';
  163. }
  164. }
  165.  
  166. ?>
  167.  
  168. $myText = (string)$myVar;
  169.  
  170. if ($_POST['submit']) {
  171. $success= mail($to, $subject, $body, $from);
  172. if($success)
  173. {
  174. echo '
  175. <p>Your message has been sent!</p>
  176. ';
  177. } else {
  178. echo '
  179. <p>Something went wrong, go back and try again!</p>
  180. ';
  181. }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement