Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SMTP Error: Could not authenticate. Message could not be sent.
- function supervisorMail(){
- global $error;
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPDebug = 0;
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = 'ssl';
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 465;
- $mail->Username = "***@gmail.com";
- $mail->Password = "****";
- $mail->SetFrom("***@gmail.com", "Employee Leave Management System");
- $userID=$_SESSION['userID'];
- $select_query = mysql_query("SELECT * FROM employee WHERE emp_id = '$userID'");
- $select_sql = mysql_fetch_array($select_query);
- $name=$select_sql['manager_name'];
- var_dump($name);
- $select_query1 = mysql_query("SELECT email FROM employee WHERE emp_id='$name'");
- $select_sql1 = mysql_fetch_array($select_query1);
- $email=$select_sql1['email'];
- var_dump($email);
- $mail->Subject = "subject ";
- $mail->Body = "something.";
- $mail_to = $email;
- $mail->AddAddress($mail_to);
- if(!$mail->Send())
- {
- echo "Message could not be sent. <p>";
- echo "Mailer Error: " . $mail->ErrorInfo;
- exit;
- }
- echo "Message has been sent";
- $mail->Username = "@gmail.com";
- $mail->Password = "";
- $mail->Username = "********@gmail.com";
- $mail->Password = "********";
- <?php
- require 'PHPMailer/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = '*****001@gmail.com'; // SMTP username
- $mail->Password = 'ma****02'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 465; // TCP port to connect to
- $mail->setFrom('ravi******@gmail.com', 'Mailer'); // Add set from id
- $mail->addAddress('er.ravihirani@gmail.com', 'Ravi Hirani'); // Add a recipient
- //$mail->addAddress('ellen@example.com'); // Name is optional
- //$mail->addReplyTo('info@example.com', 'Information');
- //$mail->addCC('cc@example.com');
- //$mail->addBCC('bcc@example.com');
- //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- //$mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- global $password; // <- this added to make script work
- $mail = new PHPMailer(true);
- try {
- $mail->isSMTP();
- // Set mailer to use SMTP
- $mail->Host = '*******.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'no-reply@*******.com';
- $mail->Password = $password;
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- $mail->setFrom('no-reply@*******.com', '******* - DO NOT REPLY');
- //$mail->isHTML(true);
- $mail->AddAddress($user->email);
- $mail->Subject = "*******";
- $mail->Body = "*******";
- $mail->send();
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
Add Comment
Please, Sign In to add comment