1<?php
2$to = $_POST['email'];
3$subject = "Email Subject";
4
5$message = 'Dear '.$_POST['name'].',<br>';
6$message .= "We welcome you to be part of family<br><br>";
7$message .= "Regards,<br>";
8
9// Always set content-type when sending HTML email
10$headers = "MIME-Version: 1.0" . "\r\n";
11$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
12
13// More headers
14$headers .= 'From: <enquiry@example.com>' . "\r\n";
15$headers .= 'Cc: myboss@example.com' . "\r\n";
16
17mail($to,$subject,$message,$headers);
18?>
1<?php
2$to = 'nobody@example.com';
3$subject = 'the subject';
4$message = 'hello';
5$headers = 'From: Jack Sparrow <jsparrow@blackpearl.com>' . PHP_EOL .
6 'Reply-To: Jack Sparrow <jsparrow@blackpearl.com>' . PHP_EOL .
7 'X-Mailer: PHP/' . phpversion();
8
9mail($to, $subject, $message, $headers);
10?>
1<?php
2require 'PHPMailerAutoload.php';
3
4$mail = new PHPMailer;
5
6//$mail->SMTPDebug = 3; // Enable verbose debug output
7
8$mail->isSMTP(); // Set mailer to use SMTP
9$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
10$mail->SMTPAuth = true; // Enable SMTP authentication
11$mail->Username = 'user@example.com'; // SMTP username
12$mail->Password = 'secret'; // SMTP password
13$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
14$mail->Port = 587; // TCP port to connect to
15
16$mail->setFrom('from@example.com', 'Mailer');
17$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
18$mail->addAddress('ellen@example.com'); // Name is optional
19$mail->addReplyTo('info@example.com', 'Information');
20$mail->addCC('cc@example.com');
21$mail->addBCC('bcc@example.com');
22
23$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
24$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
25$mail->isHTML(true); // Set email format to HTML
26
27$mail->Subject = 'Here is the subject';
28$mail->Body = 'This is the HTML message body <b>in bold!</b>';
29$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
30
31if(!$mail->send()) {
32 echo 'Message could not be sent.';
33 echo 'Mailer Error: ' . $mail->ErrorInfo;
34} else {
35 echo 'Message has been sent';
36}
1<?php
2 //Sending mail from contact form page.
3 // It works perfectly for me.
4 //Edit it and make it your own.
5
6
7 $to = "example.com@gmail.com";
8 $from = $_POST['email'];
9 $name = $_POST['name'];
10 $subject = $_POST['subject'];
11 $number = $_POST['number'];
12 $cmessage = $_POST['message'];
13
14 $headers = "From: $from";
15 $headers = "From: " . $from . "\r\n";
16 $headers .= "Reply-To: ". $from . "\r\n";
17 $headers .= "MIME-Version: 1.0\r\n";
18 $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
19
20 $subject = "You have a message from your Bitmap Photography.";
21
22 $logo = 'img/logo.png';
23 $link = '#';
24
25 $body = "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><title>Express Mail</title></head><body>";
26 $body .= "<table style='width: 100%;'>";
27 $body .= "<thead style='text-align: center;'><tr><td style='border:none;' colspan='2'>";
28 $body .= "<a href='{$link}'><img src='{$logo}' alt=''></a><br><br>";
29 $body .= "</td></tr></thead><tbody><tr>";
30 $body .= "<td style='border:none;'><strong>Name:</strong> {$name}</td>";
31 $body .= "<td style='border:none;'><strong>Email:</strong> {$from}</td>";
32 $body .= "</tr>";
33 $body .= "<tr><td style='border:none;'><strong>Subject:</strong> {$csubject}</td></tr>";
34 $body .= "<tr><td></td></tr>";
35 $body .= "<tr><td colspan='2' style='border:none;'>{$cmessage}</td></tr>";
36 $body .= "</tbody></table>";
37 $body .= "</body></html>";
38
39 $send = mail($to, $subject, $body, $headers);
40
41?>
1<?php
2// Multiple recipients
3$to = 'johny@example.com, sally@example.com'; // note the comma
4
5// Subject
6$subject = 'Birthday Reminders for August';
7
8// Message
9$message = '
10<html>
11<head>
12 <title>Birthday Reminders for August</title>
13</head>
14<body>
15 <p>Here are the birthdays upcoming in August!</p>
16 <table>
17 <tr>
18 <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
19 </tr>
20 <tr>
21 <td>Johny</td><td>10th</td><td>August</td><td>1970</td>
22 </tr>
23 <tr>
24 <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
25 </tr>
26 </table>
27</body>
28</html>
29';
30
31// To send HTML mail, the Content-type header must be set
32$headers[] = 'MIME-Version: 1.0';
33$headers[] = 'Content-type: text/html; charset=iso-8859-1';
34
35// Additional headers
36$headers[] = 'To: Mary <mary@example.com>, Kelly <kelly@example.com>';
37$headers[] = 'From: Birthday Reminder <birthday@example.com>';
38$headers[] = 'Cc: birthdayarchive@example.com';
39$headers[] = 'Bcc: birthdaycheck@example.com';
40
41// Mail it
42if(mail($to, $subject, $message, implode("\r\n", $headers))){
43 echo "success";
44}else{
45 echo "Echec send email";
46}
47;
48?>
1mail ( string $to , string $subject , string $message [, mixed $additional_headers [, string $additional_parameters ]] ) : bool