clientemail.php
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
date_default_timezone_set('Asia/Kolkata');
require 'PHPMailerAutoload.php';
include_once 'helperClass.php';
$name = $_REQUEST['fname'];
$mobile = $_REQUEST['mobile'];
$to_email = $_REQUEST['email'];
if (isset($_REQUEST['email'])) {
    /*--------------------- for sending mail start ------------------*/
    $mail_client = new PHPMailer;
    // SMTP configuration
    $mail_client->isSMTP();
    $mail_client->Host = 'smtp.gmail.com';
    $mail_client->SMTPAuth = true;
    $mail_client->SMTPDebug = 0;
    $mail_client->Debugoutput = 'html';
    $mail_client->Username = 'marketing@realatte.com';
    $mail_client->Password = 'rl@12345';
    $mail_client->SMTPSecure = 'tls';
    $mail_client->Port = 587;
    $mail_client->setFrom('marketing@realatte.com', 'Suraksha Smart City');
    $mail_client->addReplyTo('marketing@realatte.com', 'Suraksha Smart City');
    // Add a recipient
    $mail_client->addAddress($to_email);
    //$mail->addAddress('marketing@realatte.com');
    // Add cc or bcc
    //$mail->addCC('marketing@realatte.com');
    //$mail->addBCC('marketing@realatte.com');
    // Email subject
    $mail_client->Subject = 'Thank you for choosing Suraksha Smart City';
    // Set email format to HTML
    $mail_client->isHTML(true);
    // Email body content
    $mailContent = "<h1>How to send mail using PHPMailer with Attachment".$mobile."</h1>
              <p>".$to_email."The best preparation for tomorrow is doing your best today.” 
                              No one is born successful, success requires preparation .So prepare yourself online at very ease...</p>";
    $mailContent .= "<a href='http://www.webpreparations.com'><button type='submit' name='send' class='btn btn-info' style='background-color:#449D44; color:#fff; font-weight:bold;height:50px; border:1px;'>Click Her  for Visit Web Preparations</button></a>";
    // for send an attatchment
    $path = __DIR__."/upload/";
    $file_name = "suraksha-smartcity-brochure.pdf";
    $mail_client->Body = $mailContent;
    $mail_client->addAttachment($path.$file_name);
    //$mail->addStringAttachment(file_get_contents('https://path-to-pdf-file.pdf'), 'pdf-file-name.pdf');
    $mail_client->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    );
    // Send email
    if (!$mail_client->send()) {
        //echo '<div class="alert alert-danger">Mail could not be sent.</div>';
        //echo 'Mailer Error: ' . $mail->ErrorInfo;
        return true;
    } else {
        //echo '<div class="alert alert-success">Mail has been sent successfully..</div>';
        return true;
    }
    /*--------------------- for sending mail close ------------------*/
}
?>