Advertisement
Guest User

ham send mail

a guest
Jan 7th, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.49 KB | None | 0 0
  1. function sendmail($receiver_email, $receiver_name, $mail_subject, $mail_body, $mail_altbody , $mail_error, $mail_success) {
  2.         require ('phpmailer/PHPMailerAutoload.php');
  3.         /**
  4.          * This example shows settings to use when sending via Google's Gmail servers.
  5.          */
  6.         //SMTP needs accurate times, and the PHP time zone MUST be set
  7.         //This should be done in your php.ini, but this is how to do it if you don't have access to that
  8.         //date_default_timezone_set('Etc/UTC');
  9.         //Create a new PHPMailer instance
  10.         $mail = new PHPMailer;
  11.         // cat dat charset cho tieng viet
  12.         $mail->CharSet = 'UTF-8';
  13.         //Tell PHPMailer to use SMTP
  14.         $mail->isSMTP();
  15.         //Enable SMTP debugging
  16.         // 0 = off (for production use)
  17.         // 1 = client messages
  18.         // 2 = client and server messages
  19.         $mail->SMTPDebug = 0;
  20.         //Ask for HTML-friendly debug output
  21.         $mail->Debugoutput = 'html';
  22.         //Set the hostname of the mail server
  23.         $mail->Host = 'smtp.gmail.com';
  24.         //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  25.         $mail->Port = 587;
  26.         //Set the encryption system to use - ssl (deprecated) or tls
  27.         $mail->SMTPSecure = 'tls';
  28.         //Whether to use SMTP authentication
  29.         $mail->SMTPAuth = true;
  30.         //Username to use for SMTP authentication - use full email address for gmail
  31.         $mail->Username = "chieunaydidabongkhong@gmail.com";
  32.         //Password to use for SMTP authentication
  33.         $mail->Password = "anhday125";
  34.         //Set who the message is to be sent from
  35.         $mail->setFrom('chieundaydidabongkhong@gmail.com', 'Daudau wineshop');
  36.         //Set an alternative reply-to address
  37.         $mail->addReplyTo('chieundaydidabongkhong@gmail.com', 'Daudau wineshop');
  38.         //Set who the message is to be sent to
  39.         $mail->addAddress($receiver_email, $receiver_name);
  40.         //Set the subject line
  41.         $mail->Subject = "$mail_subject";
  42.         //Read an HTML message body from an external file, convert referenced images to embedded,
  43.         //convert HTML into a basic plain-text alternative body
  44.         //$mail->msgHTML(file_get_contents('include/phpmailer/examples/contents.html'), dirname(__FILE__));
  45.         $mail->Body = "$mail_body";
  46.         //Replace the plain text body with one created manually
  47.         $mail->AltBody = "$mail_altbody";
  48.         //Attach an image file
  49.         //$mail->addAttachment('include/phpmailer/examples/images/phpmailer_mini.png');
  50.         //send the message, check for errors
  51.         if (!$mail->send()) {
  52.             //echo "Mailer Error: " . $mail->ErrorInfo;
  53.             return $mail_error;
  54.         } else {
  55.             //echo "Message sent!";
  56.             return $mail_success;
  57.         }
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement