Advertisement
Guest User

Untitled

a guest
Aug 7th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.12 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. $header = "From: noreply@example.comrn";
  45. $header.= "MIME-Version: 1.0rn";
  46. $header.= "Content-Type: text/html; charset=ISO-8859-1rn";
  47. $header.= "X-Priority: 1rn";
  48.  
  49. mail($to, $subject, $message, $header);
  50.  
  51. function send_mail($email, $recipient_name, $message='')
  52. {
  53. require("phpmailer/class.phpmailer.php");
  54.  
  55. $mail = new PHPMailer();
  56.  
  57. $mail->CharSet="utf-8";
  58. $mail->IsSMTP(); // set mailer to use SMTP
  59. $mail->Host = "mail.example.com"; // specify main and backup server
  60. $mail->SMTPAuth = true; // turn on SMTP authentication
  61. $mail->Username = "myusername"; // SMTP username
  62. $mail->Password = "p@ssw0rd"; // SMTP password
  63.  
  64. $mail->From = "me@walalang.com";
  65. $mail->FromName = "System-Ad";
  66. $mail->AddAddress($email, $recipient_name);
  67.  
  68. $mail->WordWrap = 50; // set word wrap to 50 characters
  69. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  70.  
  71. $mail->Subject = "This is a Sampleenter code here Email";
  72. $mail->Body = $message;
  73. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  74. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  75. $mail->addAttachment('files/file.xlsx');
  76.  
  77. if(!$mail->Send())
  78. {
  79. echo "Message could not be sent. <p>";
  80. echo "Mailer Error: " . $mail->ErrorInfo;
  81. exit;
  82. }
  83.  
  84. echo "Message has been sent";
  85. }
  86.  
  87. $headers = "MIME-Version: 1.0" . "rn";
  88. $headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
  89. $headers .= "From: ". $from. "rn";
  90. $headers .= "Reply-To: ". $from. "rn";
  91. $headers .= "X-Mailer: PHP/" . phpversion();
  92. $headers .= "X-Priority: 1" . "rn";
  93.  
  94. mail('email@gmail.com', $subject, $message, $headers)
  95.  
  96. <?php
  97. $name = $_POST['name'];
  98. $email = $_POST['email'];
  99. $message = $_POST['message'];
  100. $from = 'From: yoursite.com';
  101. $to = 'contact@yoursite.com';
  102. $subject = 'Customer Inquiry';
  103. $body = "From: $namen E-Mail: $emailn Message:n $message";
  104.  
  105. $headers .= "MIME-Version: 1.0rn";
  106. $headers .= "Content-type: text/htmlrn";
  107. $headers = 'From: from@example.com' . "rn" .
  108. 'Reply-To: reply@example.com' . "rn" .
  109. 'X-Mailer: PHP/' . phpversion();
  110.  
  111. mail($to, $subject, $message, $headers);
  112.  
  113. $config = Array(
  114. 'protocol' => 'smtp',
  115. 'smtp_host' => 'mail.domain.com', //your smtp host
  116. 'smtp_port' => 26, //default port smtp
  117. 'smtp_user' => 'name@domain.com',
  118. 'smtp_pass' => 'password',
  119. 'mailtype' => 'html',
  120. 'charset' => 'iso-8859-1',
  121. 'wordwrap' => TRUE
  122. );
  123. $message = 'Your msg';
  124. $this->load->library('email', $config);
  125. $this->email->from('name@domain.com', 'Title');
  126. $this->email->to('emaildestination@domain.com');
  127. $this->email->subject('Header');
  128. $this->email->message($message);
  129.  
  130. if($this->email->send())
  131. {
  132. //conditional true
  133. }
  134.  
  135. <?php
  136. $name = $_POST['name'];
  137. $email = $_POST['email'];
  138. $message = $_POST['message'];
  139. $from = 'From: yoursite.com';
  140. $to = 'contact@yoursite.com';
  141. $subject = 'Customer Inquiry';
  142. $body = "From:" .$name."rn E-Mail:" .$email."rn Message:rn" .$message;
  143.  
  144. if (isset($_POST['submit']))
  145. {
  146. if (mail ($to, $subject, $body, $from))
  147. {
  148. echo '<p>Your message has been sent!</p>';
  149. }
  150. else
  151. {
  152. echo '<p>Something went wrong, go back and try again!</p>';
  153. }
  154. }
  155.  
  156. ?>
  157.  
  158. $name = $_POST['name'];
  159. $email = $_POST['email'];
  160. $reciver = '/* Reciver Email address */';
  161. if (filter_var($reciver, FILTER_VALIDATE_EMAIL)) {
  162. $subject = $name;
  163. // To send HTML mail, the Content-type header must be set.
  164. $headers = 'MIME-Version: 1.0' . "rn";
  165. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  166. $headers .= 'From:' . $email. "rn"; // Sender's Email
  167. //$headers .= 'Cc:' . $email. "rn"; // Carbon copy to Sender
  168. $template = '<div style="padding:50px; color:white;">Hello ,<br/>'
  169. . '<br/><br/>'
  170. . 'Name:' .$name.'<br/>'
  171. . 'Email:' .$email.'<br/>'
  172. . '<br/>'
  173. . '</div>';
  174. $sendmessage = "<div style="background-color:#7E7E7E; color:white;">" . $template . "</div>";
  175. // Message lines should not exceed 70 characters (PHP rule), so wrap it.
  176. $sendmessage = wordwrap($sendmessage, 70);
  177. // Send mail by PHP Mail Function.
  178. mail($reciver, $subject, $sendmessage, $headers);
  179. echo "Your Query has been received, We will contact you soon.";
  180. } else {
  181. echo "<span>* invalid email *</span>";
  182. }
  183.  
  184. <?php
  185. $SmtpServer="smtp.*.*";
  186. $SmtpPort="2525"; //default
  187. $SmtpUser="***";
  188. $SmtpPass="***";
  189. ?>
  190.  
  191. <?php
  192. class SMTPClient
  193. {
  194.  
  195. function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
  196. {
  197.  
  198. $this->SmtpServer = $SmtpServer;
  199. $this->SmtpUser = base64_encode ($SmtpUser);
  200. $this->SmtpPass = base64_encode ($SmtpPass);
  201. $this->from = $from;
  202. $this->to = $to;
  203. $this->subject = $subject;
  204. $this->body = $body;
  205.  
  206.  
  207. if ($SmtpPort == "")
  208. {
  209. $this->PortSMTP = 25;
  210. }
  211. else
  212. {
  213. $this->PortSMTP = $SmtpPort;
  214. }
  215. }
  216.  
  217. function SendMail ()
  218. {
  219. $newLine = "rn";
  220. $headers = "MIME-Version: 1.0" . $newLine;
  221. $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
  222.  
  223. if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
  224. {
  225. fputs ($SMTPIN, "EHLO ".$HTTP_HOST."rn");
  226. $talk["hello"] = fgets ( $SMTPIN, 1024 );
  227. fputs($SMTPIN, "auth loginrn");
  228. $talk["res"]=fgets($SMTPIN,1024);
  229. fputs($SMTPIN, $this->SmtpUser."rn");
  230. $talk["user"]=fgets($SMTPIN,1024);
  231. fputs($SMTPIN, $this->SmtpPass."rn");
  232. $talk["pass"]=fgets($SMTPIN,256);
  233. fputs ($SMTPIN, "MAIL FROM: <".$this->from.">rn");
  234. $talk["From"] = fgets ( $SMTPIN, 1024 );
  235. fputs ($SMTPIN, "RCPT TO: <".$this->to.">rn");
  236. $talk["To"] = fgets ($SMTPIN, 1024);
  237. fputs($SMTPIN, "DATArn");
  238. $talk["data"]=fgets( $SMTPIN,1024 );
  239. fputs($SMTPIN, "To: <".$this->to.">rnFrom: <".$this->from.">rn".$headers."nnSubject:".$this->subject."rnrnrn".$this->body."rn.rn");
  240. $talk["send"]=fgets($SMTPIN,256);
  241. //CLOSE CONNECTION AND EXIT ...
  242. fputs ($SMTPIN, "QUITrn");
  243. fclose($SMTPIN);
  244. //
  245. }
  246. return $talk;
  247. }
  248. }
  249. ?>
  250.  
  251. <?php
  252. include('SMTPconfig.php');
  253. include('SMTPmail.php');
  254. if($_SERVER["REQUEST_METHOD"] == "POST")
  255. {
  256.  
  257. $to = "";
  258. $from = $_POST['email'];
  259. $subject = "Enquiry";
  260. $body = $_POST['name'].'</br>'.$_POST['companyName'].'</br>'.$_POST['tel'].'</br>'.'<hr />'.$_POST['message'];
  261. $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
  262. $SMTPChat = $SMTPMail->SendMail();
  263. }
  264. ?>
  265.  
  266. if ($_POST['submit']) {
  267. $success= mail($to, $subject, $body, $from);
  268. if($success)
  269. {
  270. echo '
  271. <p>Your message has been sent!</p>
  272. ';
  273. } else {
  274. echo '
  275. <p>Something went wrong, go back and try again!</p>
  276. ';
  277. }
  278. }
  279.  
  280. $mail->SMTPDebug = 2;
  281.  
  282. try this
  283. <?php
  284. $to = "somebody@example.com, somebodyelse@example.com";
  285. $subject = "HTML email";
  286.  
  287. $message = "
  288. <html>
  289. <head>
  290. <title>HTML email</title>
  291. </head>
  292. <body>
  293. <p>This email contains HTML Tags!</p>
  294. <table>
  295. <tr>
  296. <th>Firstname</th>
  297. <th>Lastname</th>
  298. </tr>
  299. <tr>
  300. <td>John</td>
  301. <td>Doe</td>
  302. </tr>
  303. </table>
  304. </body>
  305. </html>
  306. ";
  307.  
  308. // Always set content-type when sending HTML email
  309. $headers = "MIME-Version: 1.0" . "rn";
  310. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  311.  
  312. // More headers
  313. $headers .= 'From: <webmaster@example.com>' . "rn";
  314. $headers .= 'Cc: myboss@example.com' . "rn";
  315.  
  316. mail($to,$subject,$message,$headers);
  317. ?>
  318.  
  319. <?php
  320.  
  321. error_reporting(0);
  322. $name = $_POST['name'];
  323. $email = $_POST['email'];
  324. $message = $_POST['message'];
  325. $from = 'From: yoursite.com';
  326. $to = 'contact@yoursite.com';
  327. $subject = 'Customer Inquiry';
  328. $body = "From: $namen E-Mail: $emailn Message:n $message";
  329.  
  330.  
  331. if ($_POST['submit']){
  332. if (!(empty($_POST['name']))) {
  333. if (!(empty($_POST['email']))){
  334. if (!(empty($_POST['message']))){
  335. mail ($to, $subject, $body, $from);
  336. echo '<p>Your message has been sent!</p>';
  337. }else{
  338. echo '<p>Fill your message please.</p>';}
  339. }else {
  340. echo '<p>Fill your email please.</p>';}
  341. }else{
  342. echo '<p>Fill your name please.</p>';}
  343. }else{
  344. echo '<p>Fill the form.</p>';}
  345. ?>
  346.  
  347. <html>
  348. <form method="post" action="?">
  349. <table>
  350. <tr><td>Name</td><td><input type='text' name='name' id='name'/></td></tr>
  351. <tr><td>Email</td><td><input type='text' name='email' id='email'/></td></tr>
  352. <tr><td>Message</td><td><input type='text' name='message' id='message'/></td></tr>
  353. <tr><td></td><td><input type='submit' name='submit' id='submit'/></td></tr>
  354. </table>
  355. </form>
  356. </html>
  357.  
  358. $name = $_POST['name'];
  359. $email = $_POST['email'];
  360. $message = $_POST['message'];
  361. $from = 'From: yoursite.com';
  362. $to = 'contact@yoursite.com';
  363. $subject = 'Customer Inquiry';
  364. $body = "From: $namen E-Mail: $emailn Message:n $message";
  365.  
  366. require 'mail/swift_required.php';
  367.  
  368. $message = Swift_Message::newInstance()
  369. // The subject of your email
  370. ->setSubject('Jane Doe sends you a message')
  371. // The from address(es)
  372. ->setFrom(array('jane.doe@gmail.com' => 'Jane Doe'))
  373. // The to address(es)
  374. ->setTo(array('frank.stevens@gmail.com' => 'Frank Stevens'))
  375. // Here, you put the content of your email
  376. ->setBody('<h3>New message</h3><p>Here goes the rest of my message</p>', 'text/html');
  377.  
  378. if (Swift_Mailer::newInstance(Swift_MailTransport::newInstance())->send($message)) {
  379. echo json_encode([
  380. "status" => "OK",
  381. "message" => 'Your message has been sent!'
  382. ], JSON_PRETTY_PRINT);
  383. } else {
  384. echo json_encode([
  385. "status" => "error",
  386. "message" => 'Oops! Something went wrong!'
  387. ], JSON_PRETTY_PRINT);
  388. }
  389.  
  390. $myText = (string)$myVar;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement