fork download
  1. <?php
  2. //goi thu vien
  3. require 'class.smtp.php';
  4. require 'class.phpmailer.php';
  5. require 'PHPMailerAutoload.php';
  6. $nFrom = ""; //mail duoc gui tu dau, thuong de ten cong ty ban
  7. $mFrom = ''; //dia chi email cua ban
  8. $mPass = ''; //mat khau email cua ban
  9. $nTo = ''; //Ten nguoi nhan
  10. $mTo = ''; //dia chi nhan mail
  11. $mail = new PHPMailer();
  12. $body = 'Bạn đang tìm hiểu về cách gửi email bằng php mailler chúc các bạn có những phút giây vui vẻ.'; // Noi dung email
  13. $title = 'Hướng dẫn gửi mail bằng PHPMailer'; //Tieu de gui mail
  14. $mail->IsSMTP();
  15. $mail->CharSet = "utf-8";
  16. $mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
  17. $mail->SMTPAuth = true; // enable SMTP authentication
  18. $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
  19. $mail->Host = "smtp.gmail.com"; // sever gui mail.
  20. $mail->Port = 465; // cong gui mail de nguyen
  21. // xong phan cau hinh bat dau phan gui mail
  22. $mail->Username = $mFrom; // khai bao dia chi email
  23. $mail->Password = $mPass; // khai bao mat khau
  24. $mail->SetFrom($mFrom, $nFrom);
  25. $mail->AddReplyTo('16521215@gm.uit.edu.vn', 'abc'); //khi nguoi dung phan hoi se duoc gui den email nay
  26. $mail->Subject = $title;// tieu de email
  27. $mail->MsgHTML($body);// noi dung chinh cua mail se nam o day.
  28. $mail->AddAddress($mTo, $nTo);
  29. // thuc thi lenh gui mail
  30. if(!$mail->Send()) {
  31. echo 'Co loi!';
  32.  
  33. } else {
  34.  
  35. echo 'mail của bạn đã được gửi đi hãy kiếm tra hộp thư đến để xem kết quả. ';
  36. }
  37. ?>
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:13: warning: character constant too long for its type
     require 'class.smtp.php';
             ^~~~~~~~~~~~~~~~
prog.cpp:4:13: warning: character constant too long for its type
     require 'class.phpmailer.php';
             ^~~~~~~~~~~~~~~~~~~~~
prog.cpp:5:13: warning: character constant too long for its type
     require 'PHPMailerAutoload.php';
             ^~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:7:14: error: empty character constant
     $mFrom = '';  //dia chi email cua ban
              ^~
prog.cpp:8:14: error: empty character constant
     $mPass = '';       //mat khau email cua ban
              ^~
prog.cpp:9:12: error: empty character constant
     $nTo = ''; //Ten nguoi nhan
            ^~
prog.cpp:10:12: error: empty character constant
     $mTo = '';   //dia chi nhan mail
            ^~
prog.cpp:12:25: warning: character constant too long for its type
     $body             = 'Bạn đang tìm hiểu về cách gửi email bằng php mailler chúc các bạn có những phút giây vui vẻ.';   // Noi dung email
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:13:14: warning: character constant too long for its type
     $title = 'Hướng dẫn gửi mail bằng PHPMailer';   //Tieu de gui mail
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:25:23: warning: character constant too long for its type
     $mail->AddReplyTo('16521215@gm.uit.edu.vn', 'abc'); //khi nguoi dung phan hoi se duoc gui den email nay
                       ^~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:25:49: warning: multi-character character constant [-Wmultichar]
     $mail->AddReplyTo('16521215@gm.uit.edu.vn', 'abc'); //khi nguoi dung phan hoi se duoc gui den email nay
                                                 ^~~~~
prog.cpp:31:14: warning: character constant too long for its type
         echo 'Co loi!';
              ^~~~~~~~~
prog.cpp:35:14: warning: character constant too long for its type
         echo 'mail của bạn đã được gửi đi hãy kiếm tra hộp thư đến để xem kết quả. ';
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:1:1: error: expected unqualified-id before ‘<’ token
 <?php
 ^
prog.cpp:4:5: error: ‘require’ does not name a type
     require 'class.phpmailer.php';
     ^~~~~~~
prog.cpp:5:5: error: ‘require’ does not name a type
     require 'PHPMailerAutoload.php';
     ^~~~~~~
prog.cpp:6:5: error: ‘$nFrom’ does not name a type
     $nFrom = "";    //mail duoc gui tu dau, thuong de ten cong ty ban
     ^~~~~~
prog.cpp:7:5: error: ‘$mFrom’ does not name a type
     $mFrom = '';  //dia chi email cua ban
     ^~~~~~
prog.cpp:8:5: error: ‘$mPass’ does not name a type
     $mPass = '';       //mat khau email cua ban
     ^~~~~~
prog.cpp:9:5: error: ‘$nTo’ does not name a type
     $nTo = ''; //Ten nguoi nhan
     ^~~~
prog.cpp:10:5: error: ‘$mTo’ does not name a type
     $mTo = '';   //dia chi nhan mail
     ^~~~
prog.cpp:11:5: error: ‘$mail’ does not name a type
     $mail             = new PHPMailer();
     ^~~~~
prog.cpp:12:5: error: ‘$body’ does not name a type
     $body             = 'Bạn đang tìm hiểu về cách gửi email bằng php mailler chúc các bạn có những phút giây vui vẻ.';   // Noi dung email
     ^~~~~
prog.cpp:13:5: error: ‘$title’ does not name a type
     $title = 'Hướng dẫn gửi mail bằng PHPMailer';   //Tieu de gui mail
     ^~~~~~
prog.cpp:14:5: error: ‘$mail’ does not name a type
     $mail->IsSMTP();
     ^~~~~
prog.cpp:15:5: error: ‘$mail’ does not name a type
     $mail->CharSet  = "utf-8";
     ^~~~~
prog.cpp:16:5: error: ‘$mail’ does not name a type
     $mail->SMTPDebug  = 0;   // enables SMTP debug information (for testing)
     ^~~~~
prog.cpp:17:5: error: ‘$mail’ does not name a type
     $mail->SMTPAuth   = true;    // enable SMTP authentication
     ^~~~~
prog.cpp:18:5: error: ‘$mail’ does not name a type
     $mail->SMTPSecure = "ssl";   // sets the prefix to the servier
     ^~~~~
prog.cpp:19:5: error: ‘$mail’ does not name a type
     $mail->Host       = "smtp.gmail.com";    // sever gui mail.
     ^~~~~
prog.cpp:20:5: error: ‘$mail’ does not name a type
     $mail->Port       = 465;         // cong gui mail de nguyen
     ^~~~~
prog.cpp:22:5: error: ‘$mail’ does not name a type
     $mail->Username   = $mFrom;  // khai bao dia chi email
     ^~~~~
prog.cpp:23:5: error: ‘$mail’ does not name a type
     $mail->Password   = $mPass;              // khai bao mat khau
     ^~~~~
prog.cpp:24:5: error: ‘$mail’ does not name a type
     $mail->SetFrom($mFrom, $nFrom);
     ^~~~~
prog.cpp:25:5: error: ‘$mail’ does not name a type
     $mail->AddReplyTo('16521215@gm.uit.edu.vn', 'abc'); //khi nguoi dung phan hoi se duoc gui den email nay
     ^~~~~
prog.cpp:26:5: error: ‘$mail’ does not name a type
     $mail->Subject    = $title;// tieu de email
     ^~~~~
prog.cpp:27:5: error: ‘$mail’ does not name a type
     $mail->MsgHTML($body);// noi dung chinh cua mail se nam o day.
     ^~~~~
prog.cpp:28:5: error: ‘$mail’ does not name a type
     $mail->AddAddress($mTo, $nTo);
     ^~~~~
prog.cpp:30:5: error: expected unqualified-id before ‘if’
     if(!$mail->Send()) {
     ^~
prog.cpp:33:7: error: expected unqualified-id before ‘else’
     } else {
       ^~~~
prog.cpp:37:1: error: expected unqualified-id before ‘?’ token
 ?>
 ^
stdout
Standard output is empty