Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include the PHPMailer classes
- // If these are located somewhere else, simply change the path.
- require_once("PHPMailer/class.phpmailer.php");
- require_once("PHPMailer/class.smtp.php");
- require_once("PHPMailer/language/phpmailer.lang-ar.php");
- // mostly the same variables as before
- // ($to_name & $from_name are new, $headers was omitted)
- $to_name = "tp mail";
- $to = "sunil.gandhi007@gmail.com";
- $subject = "Mail Test at ".strftime("%T", time());
- $message = "This is a test.";
- $message = wordwrap($message,70);
- $from_name = "sunil";
- $from = "sunil.gandhi007@gmail.com";
- // PHPMailer's Object-oriented approach
- $mail = new PHPMailer();
- // Can use SMTP
- // comment out this section and it will use PHP mail() instead
- $mail->IsSMTP();
- $mail->Host = "smtp.gmail.com";
- $mail->Port = 587;
- $mail->SMTPAuth = true;
- $mail->Username = "username@gmail.com";
- $mail->Password = "mygmailpass";
- // Could assign strings directly to these, I only used the
- // former variables to illustrate how similar the two approaches are.
- $mail->FromName = $from_name;
- $mail->From = $from;
- $mail->AddAddress($to, $to_name);
- $mail->Subject = $subject;
- $mail->Body = $message;
- $result = $mail->Send();
- echo $result ? 'Sent' : 'Error';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement