<?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 ------------------*/ } ?>