Guest User

Untitled

a guest
Aug 21st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.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. $headers = array("From: $_POST[contactform_sender_email]"); // No!
  36.  
  37. $to = 'user@example.com';
  38. // other variables ....
  39. mail($recipient, $subject, $message, $headers); // $recipient should be $to
  40.  
  41. mail('user@example.com', $subject, $message, $headers);
  42.  
  43. <form action="send_email.php" method="POST">
  44.  
  45. ini_set("mail.log", "/tmp/mail.log");
  46. ini_set("mail.add_x_header", TRUE);
  47.  
  48. $header = "From: noreply@example.comrn";
  49. $header.= "MIME-Version: 1.0rn";
  50. $header.= "Content-Type: text/html; charset=ISO-8859-1rn";
  51. $header.= "X-Priority: 1rn";
  52.  
  53. $status = mail($to, $subject, $message, $header);
  54.  
  55. if($status)
  56. {
  57. echo '<p>Your mail has been sent!</p>';
  58. } else {
  59. echo '<p>Something went wrong, Please try again!</p>';
  60. }
  61.  
  62. function send_mail($email, $recipient_name, $message='')
  63. {
  64. require("phpmailer/class.phpmailer.php");
  65.  
  66. $mail = new PHPMailer();
  67.  
  68. $mail->CharSet="utf-8";
  69. $mail->IsSMTP(); // set mailer to use SMTP
  70. $mail->Host = "mail.example.com"; // specify main and backup server
  71. $mail->SMTPAuth = true; // turn on SMTP authentication
  72. $mail->Username = "myusername"; // SMTP username
  73. $mail->Password = "p@ssw0rd"; // SMTP password
  74.  
  75. $mail->From = "me@walalang.com";
  76. $mail->FromName = "System-Ad";
  77. $mail->AddAddress($email, $recipient_name);
  78.  
  79. $mail->WordWrap = 50; // set word wrap to 50 characters
  80. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  81.  
  82. $mail->Subject = "This is a Sampleenter code here Email";
  83. $mail->Body = $message;
  84. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  85. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  86. $mail->addAttachment('files/file.xlsx');
  87.  
  88. if(!$mail->Send())
  89. {
  90. echo "Message could not be sent. <p>";
  91. echo "Mailer Error: " . $mail->ErrorInfo;
  92. exit;
  93. }
  94.  
  95. echo "Message has been sent";
  96. }
  97.  
  98. <?php
  99. $name = $_POST['name'];
  100. $email = $_POST['email'];
  101. $message = $_POST['message'];
  102. $from = 'From: yoursite.com';
  103. $to = 'contact@yoursite.com';
  104. $subject = 'Customer Inquiry';
  105. $body = "From: $namen E-Mail: $emailn Message:n $message";
  106.  
  107. $headers .= "MIME-Version: 1.0rn";
  108. $headers .= "Content-type: text/htmlrn";
  109. $headers .= 'From: from@example.com' . "rn" .
  110. 'Reply-To: reply@example.com' . "rn" .
  111. 'X-Mailer: PHP/' . phpversion();
  112.  
  113. mail($to, $subject, $message, $headers);
  114.  
  115. $headers = "MIME-Version: 1.0" . "rn";
  116. $headers .= "Content-type: text/html; charset=iso-8859-1" . "rn";
  117. $headers .= "From: ". $from. "rn";
  118. $headers .= "Reply-To: ". $from. "rn";
  119. $headers .= "X-Mailer: PHP/" . phpversion();
  120. $headers .= "X-Priority: 1" . "rn";
  121.  
  122. mail('email@gmail.com', $subject, $message, $headers)
  123.  
  124. <?php
  125. $SmtpServer="smtp.*.*";
  126. $SmtpPort="2525"; //default
  127. $SmtpUser="***";
  128. $SmtpPass="***";
  129. ?>
  130.  
  131. <?php
  132. class SMTPClient
  133. {
  134.  
  135. function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
  136. {
  137.  
  138. $this->SmtpServer = $SmtpServer;
  139. $this->SmtpUser = base64_encode ($SmtpUser);
  140. $this->SmtpPass = base64_encode ($SmtpPass);
  141. $this->from = $from;
  142. $this->to = $to;
  143. $this->subject = $subject;
  144. $this->body = $body;
  145.  
  146. if ($SmtpPort == "")
  147. {
  148. $this->PortSMTP = 25;
  149. }
  150. else
  151. {
  152. $this->PortSMTP = $SmtpPort;
  153. }
  154. }
  155.  
  156. function SendMail ()
  157. {
  158. $newLine = "rn";
  159. $headers = "MIME-Version: 1.0" . $newLine;
  160. $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;
  161.  
  162. if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
  163. {
  164. fputs ($SMTPIN, "EHLO ".$HTTP_HOST."rn");
  165. $talk["hello"] = fgets ( $SMTPIN, 1024 );
  166. fputs($SMTPIN, "auth loginrn");
  167. $talk["res"]=fgets($SMTPIN,1024);
  168. fputs($SMTPIN, $this->SmtpUser."rn");
  169. $talk["user"]=fgets($SMTPIN,1024);
  170. fputs($SMTPIN, $this->SmtpPass."rn");
  171. $talk["pass"]=fgets($SMTPIN,256);
  172. fputs ($SMTPIN, "MAIL FROM: <".$this->from.">rn");
  173. $talk["From"] = fgets ( $SMTPIN, 1024 );
  174. fputs ($SMTPIN, "RCPT TO: <".$this->to.">rn");
  175. $talk["To"] = fgets ($SMTPIN, 1024);
  176. fputs($SMTPIN, "DATArn");
  177. $talk["data"]=fgets( $SMTPIN,1024 );
  178. fputs($SMTPIN, "To: <".$this->to.">rnFrom: <".$this->from.">rn".$headers."nnSubject:".$this->subject."rnrnrn".$this->body."rn.rn");
  179. $talk["send"]=fgets($SMTPIN,256);
  180. //CLOSE CONNECTION AND EXIT ...
  181. fputs ($SMTPIN, "QUITrn");
  182. fclose($SMTPIN);
  183. //
  184. }
  185. return $talk;
  186. }
  187. }
  188. ?>
  189.  
  190. <?php
  191. include('SMTPconfig.php');
  192. include('SMTPmail.php');
  193. if($_SERVER["REQUEST_METHOD"] == "POST")
  194. {
  195. $to = "";
  196. $from = $_POST['email'];
  197. $subject = "Enquiry";
  198. $body = $_POST['name'].'</br>'.$_POST['companyName'].'</br>'.$_POST['tel'].'</br>'.'<hr />'.$_POST['message'];
  199. $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
  200. $SMTPChat = $SMTPMail->SendMail();
  201. }
  202. ?>
  203.  
  204. $mail->SMTPDebug = 2;
  205.  
  206. <?php
  207. $name = $_POST['name'];
  208. $email = $_POST['email'];
  209. $message = $_POST['message'];
  210. $from = 'From: yoursite.com';
  211. $to = 'contact@yoursite.com';
  212. $subject = 'Customer Inquiry';
  213. $body = "From:" .$name."rn E-Mail:" .$email."rn Message:rn" .$message;
  214.  
  215. if (isset($_POST['submit']))
  216. {
  217. if (mail ($to, $subject, $body, $from))
  218. {
  219. echo '<p>Your message has been sent!</p>';
  220. }
  221. else
  222. {
  223. echo '<p>Something went wrong, go back and try again!</p>';
  224. }
  225. }
  226.  
  227. ?>
  228.  
  229. $config = Array(
  230. 'protocol' => 'smtp',
  231. 'smtp_host' => 'mail.domain.com', //your smtp host
  232. 'smtp_port' => 26, //default port smtp
  233. 'smtp_user' => 'name@domain.com',
  234. 'smtp_pass' => 'password',
  235. 'mailtype' => 'html',
  236. 'charset' => 'iso-8859-1',
  237. 'wordwrap' => TRUE
  238. );
  239. $message = 'Your msg';
  240. $this->load->library('email', $config);
  241. $this->email->from('name@domain.com', 'Title');
  242. $this->email->to('emaildestination@domain.com');
  243. $this->email->subject('Header');
  244. $this->email->message($message);
  245.  
  246. if($this->email->send())
  247. {
  248. //conditional true
  249. }
  250.  
  251. $name = $_POST['name'];
  252. $email = $_POST['email'];
  253. $reciver = '/* Reciver Email address */';
  254. if (filter_var($reciver, FILTER_VALIDATE_EMAIL)) {
  255. $subject = $name;
  256. // To send HTML mail, the Content-type header must be set.
  257. $headers = 'MIME-Version: 1.0' . "rn";
  258. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  259. $headers .= 'From:' . $email. "rn"; // Sender's Email
  260. //$headers .= 'Cc:' . $email. "rn"; // Carbon copy to Sender
  261. $template = '<div style="padding:50px; color:white;">Hello ,<br/>'
  262. . '<br/><br/>'
  263. . 'Name:' .$name.'<br/>'
  264. . 'Email:' .$email.'<br/>'
  265. . '<br/>'
  266. . '</div>';
  267. $sendmessage = "<div style="background-color:#7E7E7E; color:white;">" . $template . "</div>";
  268. // Message lines should not exceed 70 characters (PHP rule), so wrap it.
  269. $sendmessage = wordwrap($sendmessage, 70);
  270. // Send mail by PHP Mail Function.
  271. mail($reciver, $subject, $sendmessage, $headers);
  272. echo "Your Query has been received, We will contact you soon.";
  273. } else {
  274. echo "<span>* invalid email *</span>";
  275. }
  276.  
  277. <?php
  278. $to = "somebody@example.com, somebodyelse@example.com";
  279. $subject = "HTML email";
  280.  
  281. $message = "
  282. <html>
  283. <head>
  284. <title>HTML email</title>
  285. </head>
  286. <body>
  287. <p>This email contains HTML Tags!</p>
  288. <table>
  289. <tr>
  290. <th>Firstname</th>
  291. <th>Lastname</th>
  292. </tr>
  293. <tr>
  294. <td>John</td>
  295. <td>Doe</td>
  296. </tr>
  297. </table>
  298. </body>
  299. </html>";
  300.  
  301. // Always set content-type when sending HTML email
  302. $headers = "MIME-Version: 1.0" . "rn";
  303. $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  304.  
  305. // More headers
  306. $headers .= 'From: <webmaster@example.com>' . "rn";
  307. $headers .= 'Cc: myboss@example.com' . "rn";
  308.  
  309. mail($to,$subject,$message,$headers);
  310. ?>
  311.  
  312. if ($_POST['submit']) {
  313. $success= mail($to, $subject, $body, $from);
  314. if($success)
  315. {
  316. echo '
  317. <p>Your message has been sent!</p>
  318. ';
  319. } else {
  320. echo '
  321. <p>Something went wrong, go back and try again!</p>
  322. ';
  323. }
  324. }
  325.  
  326. $name = $_POST['name'];
  327. $email = $_POST['email'];
  328. $message = $_POST['message'];
  329. $from = 'From: yoursite.com';
  330. $to = 'contact@yoursite.com';
  331. $subject = 'Customer Inquiry';
  332. $body = "From: $namen E-Mail: $emailn Message:n $message";
  333.  
  334. require 'mail/swift_required.php';
  335.  
  336. $message = Swift_Message::newInstance()
  337. // The subject of your email
  338. ->setSubject('Jane Doe sends you a message')
  339. // The from address(es)
  340. ->setFrom(array('jane.doe@gmail.com' => 'Jane Doe'))
  341. // The to address(es)
  342. ->setTo(array('frank.stevens@gmail.com' => 'Frank Stevens'))
  343. // Here, you put the content of your email
  344. ->setBody('<h3>New message</h3><p>Here goes the rest of my message</p>', 'text/html');
  345.  
  346. if (Swift_Mailer::newInstance(Swift_MailTransport::newInstance())->send($message)) {
  347. echo json_encode([
  348. "status" => "OK",
  349. "message" => 'Your message has been sent!'
  350. ], JSON_PRETTY_PRINT);
  351. } else {
  352. echo json_encode([
  353. "status" => "error",
  354. "message" => 'Oops! Something went wrong!'
  355. ], JSON_PRETTY_PRINT);
  356. }
  357.  
  358. sudo apt-get install sendmail
  359.  
  360. require_once 'PHPMailer/PHPMailer.php';
  361. require_once '/servicios/PHPMailer/SMTP.php';
  362. require_once '/servicios/PHPMailer/Exception.php';
  363.  
  364. $mail = new PHPMailerPHPMailerPHPMailer(true);
  365. try {
  366. //Server settings
  367. $mail->SMTPDebug = 0;
  368. $mail->isSMTP();
  369. $mail->Host = 'smtp.gmail.com';
  370. $mail->SMTPAuth = true;
  371. $mail->Username = 'correo@gmail.com';
  372. $mail->Password = 'contrasenia';
  373. $mail->SMTPSecure = 'ssl';
  374. $mail->Port = 465;
  375.  
  376. //Recipients
  377. $mail->setFrom('correo@gmail.com', 'my name');
  378. $mail->addAddress('destination@correo.com');
  379.  
  380. //Attachments
  381. $mail->addAttachment('optional file'); // Add files, is optional
  382.  
  383. //Content
  384. $mail->isHTML(true);// Set email format to HTML
  385. $mail->Subject = utf8_decode("subject");
  386. $mail->Body = utf8_decode("mail content");
  387. $mail->AltBody = '';
  388. $mail->send();
  389. }
  390. catch (Exception $e){
  391. $error = $mail->ErrorInfo;
  392. }
  393.  
  394. From: myapp@example.com
  395. To: mymail@example.com
  396. Subject: Test mail via sendmail.
  397.  
  398. Text body.
  399.  
  400. root=mymail@example.com
  401. mailhub=smtp.yandex.ru:465
  402. FromLineOverride=YES
  403. UseTLS=YES
  404. AuthUser=abcde@yandex.ru
  405. AuthPass=password
  406.  
  407. <?php
  408. $to = 'nobody@example.com';
  409. $subject = 'the subject';
  410. $message = 'hello';
  411. $headers = 'From: webmaster@example.com' . "rn" .
  412. 'Reply-To: webmaster@example.com' . "rn" .
  413. 'X-Mailer: PHP/' . phpversion();
  414.  
  415. mail($to, $subject, $message, $headers);
  416. ?>
  417.  
  418. include "libmail.php";
  419. $m = new Mail(); // create the mail
  420. $m->From( $_POST['form'] );
  421. $m->To( $_POST['to'] );
  422. $m->Subject( $_POST['subject'] );
  423. $m->Body( $_POST['body'] );
  424. $m->Cc( $_POST['cc']);
  425. $m->Priority(4);
  426. // attach a file of type image/gif to be displayed in the message if possible
  427. $m->Attach( "/home/leo/toto.gif", "image/gif", "inline" );
  428. $m->Send(); // send the mail
  429. echo "Mail was sent:"
  430. echo $m->Get(); // show the mail source
  431.  
  432. [mail function]
  433. sendmail_path=/usr/sbin/sendmail -t -i
  434. ; (Other directives are mostly windows)
  435.  
  436. su - # Install as user 'root'
  437. dpkg --list # Is install necessary?
  438. apt-get install sendmail sendmail-cf m4 # Note multiple package selection
  439. sendmailconfig # Respond all 'Y' for new install
  440.  
  441. which sendmail # /usr/sbin/sendmail
  442. which sendmailconfig # /usr/sbin/sendmailconfig
  443. man sendmail # Documentation
  444. systemctl restart sendmail # As and when required
  445.  
  446. echo "Subject: sendmail test" | sendmail -v <yourEmail>@gmail.com
  447.  
  448. error_reporting(E_ALL);
  449.  
  450. <?php
  451. use PHPMailerPHPMailerPHPMailer;
  452. require 'PHPMailer.php';
  453. require 'SMTP.php';
  454. require 'Exception.php';
  455. $name=$_POST['name'];
  456. $mailid=$_POST['mail'];
  457. $mail = new PHPMailer;
  458. $mail->IsSMTP();
  459. $mail->SMTPDebug = 0; // Set mailer to use SMTP
  460. $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
  461. $mail->Port = 587; // Set the SMTP port
  462. $mail->SMTPAuth = true; // Enable SMTP authentication
  463. $mail->Username = 'someone@gmail.com'; // SMTP username
  464. $mail->Password = 'password'; // SMTP password
  465. $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  466.  
  467. $mail->From = 'someone@gmail.com';
  468. $mail->FromName = 'name';
  469. $mail->AddAddress($mailid,$name); // Name is optional
  470. $mail->IsHTML(true); // Set email format to HTML
  471. $mail->Subject = 'Here is the subject';
  472. $mail->Body = 'Here is your message' ;
  473. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  474. if(!$mail->Send()) {
  475. echo 'Message could not be sent.';
  476. echo 'Mailer Error: ' . $mail->ErrorInfo;
  477. exit;
  478. }
  479. echo 'Message has been sent';
  480. ?>
  481.  
  482. <?php
  483. $name = $_POST['name'];
  484. $email = $_POST['email'];
  485. $message = $_POST['message'];
  486.  
  487. $header ="
  488. Content-Type: text/html; charset=UTF-8rn
  489. MIME-Version: 1.0rn
  490. From: "$name" <$email>rn
  491. Reply-To: no-reply@yoursite.comrn
  492. X-Mailer: yoursite.com mailerrn
  493. ";
  494.  
  495. $to = '"Contact" <contact@yoursite.com>';
  496. $subject = 'Customer Inquiry';
  497. $body =<<<EOB
  498. <!DOCTYPE html>
  499. <html>
  500. <body>
  501. $message
  502. </body>
  503. </html>
  504. EOB;
  505.  
  506. if ($_POST['submit']) {
  507. if (mail ($to, $subject, $body, $header) !== false) {
  508. echo '<p>Your message has been sent!</p>';
  509. } else {
  510. echo '<p>Something went wrong, go back and try again!</p>';
  511. }
  512. }
  513. ?>
  514.  
  515. <?php
  516.  
  517. require_once ("PHPMailer/PHPMailerAutoload.php");
  518.  
  519. $error = array();
  520.  
  521. //var_dump($_POST);
  522.  
  523. $message = $_POST['a'] . '<br>';
  524. $message.= $_POST['b'] . '<br>';
  525. $message.= $_POST['c'] . '<br>';
  526. $message.= $_POST['d'] . '<br>';
  527. $message.= $_POST['e'] . '<br>';
  528. $message.= $_POST['f'] . '<br>';
  529. $message.= $_POST['g'] . '<br>';
  530. $message.= $_POST['h'] . '<br>';
  531. $message.= $_POST['i'] . '<br>';
  532. $message.= $_POST['j'] . '<br>';
  533. $message.= $_POST['k'] . '<br>';
  534.  
  535. $subject = "Visitor Query";
  536. $from = "******@******.com"; // example a@b.com
  537. $password = '******';
  538.  
  539. $mail = new PHPMailer();
  540. $body = $message;
  541. $mail->IsSMTP();
  542. $mail->SMTPAuth = true; // turn on SMTP authentication
  543. $mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
  544. $mail->SMTPDebug = 0;
  545.  
  546. //$mail->Host = 'mail.******.com'; // sets SMTP server
  547. $mail->Host = 'mail.******.com'; // sets SMTP server
  548. $mail->SMTPSecure = 'ssl';
  549. $mail->Port = 465;
  550. //$mail->Port = 25;
  551.  
  552. $mail->Username = $from; // SMTP username
  553. $mail->Password = $password; // SMTP password
  554.  
  555. $mail->AddAddress ( "******@gmail.com" );
  556. $mail->AddReplyTo ( "******@gmail.com", "Team");
  557. $mail->Subject = $subject;
  558. $mail->Body = $message;
  559. $mail->From = $from;
  560. $mail->FromName = "Visitor's Query";
  561. $mail->ContentType = "text/html";
  562.  
  563. if (count($error == 0)) {
  564.  
  565. $mail->Send();
  566.  
  567. // echo "_________________wait_______for_______ our _______ reply !";
  568.  
  569.  
  570. } else {
  571.  
  572. echo $error; // show error messages
  573. //echo $result;
  574. }
  575.  
  576. //header("location: index.php");
  577.  
  578. ?>
Add Comment
Please, Sign In to add comment