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// 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?>
1<?php
2 include "emails/PHPMailer/PHPMailerAutoload.php";
3 //or just include the php mailer class
4 //Create a new PHPMailer instance
5 $mail = new PHPMailer();
6
7 $mail->IsSMTP();
8 $mail->SMTPDebug = 1;
9 $mail->SMTPAuth = true;
10 $mail->SMTPSecure = 'ssl';
11 $mail->Host = "smtp.gmail.com";
12 /*
13
14 you also need to set the `allow less secure app` = ON
15 in your gmail account which you want to use here
16 :)
17 on then you will be able to send the emails from your account
18 using phpMailer
19
20 */
21 $mail->Port = 465;
22 $mail->IsHTML(true);
23 //Username to use for SMTP authentication
24 $mail->Username = "@gmail.com";
25 $mail->Password = "";
26 //Set who the message is to be sent from
27 $mail->setFrom('mzubim@gmail.com', 'Zubair Mushtaq');
28 //Set an alternative reply-to address
29 $mail->addReplyTo('replyto@gmail.com', 'Secure Developer');
30 //Set who the message is to be sent to
31 $mail->addAddress('abulogics@gmail.com', 'Abulogicss');
32 //Set the subject line
33 $mail->Subject = 'PHPMailer SMTP test';
34 //Read an HTML message body from an external file, convert referenced images to embedded,
35 //convert HTML into a basic plain-text alternative body
36 $mail->msgHTML("convert HTML into a basic plain-text alternative body");
37 //Replace the plain text body with one created manually
38 $mail->AltBody = 'This is a plain-text message body';
39
40 //send the message, check for errors
41 if (!$mail->send()) {
42 echo "Mailer Error: " . $mail->ErrorInfo;
43 } else {
44 echo "Message sent!";
45 }