Advertisement
Guest User

Untitled

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