www.webdeveloper.com
Results 1 to 2 of 2

Thread: probleme with php mailer class

  1. #1
    Join Date
    Aug 2012
    Posts
    1

    probleme with php mailer class

    hello eveyone;
    i was wondering if somebody has already tried to use phpmailer locally with wamp server . i am trying to this all i could reach is to use the phpmailer without using the smtp functionalities.

    so this works ;

    require_once("PHPMailer/class.phpmailer.php");
    require_once("PHPMailer/class.smtp.php");
    require_once("PHPMailer/language/phpmailer.lang-fr.php");
    /*date_default_timezone_set("Europe/Zurich");*/

    // mostly the same variables as before
    // ($to_name & $from_name are new, $headers was omitted)
    $to_name = "Recipient Name";
    $to = "tomail@provider.com";
    $subject = "Mail de test at ";
    $message = "This is a test.";
    $message = wordwrap($message,70);
    $from_name = "Sender Name";
    $from = "frommail@providerl.com";

    $mail = new PHPMailer();
    $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 : '.$mail->ErrorInfo;

    this works pretty much good though it send the mail to the spam for hotmail.

    but when i add this

    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'smtp.gmail.com'; // i am trying to use my gmail as an smtp
    $mail->Port = 465;
    $mail->Username = "mygmail@gmail.com";
    $mail->Password = "mygmailpassword";

    the truth is that i don't understand a lot in emailing so if anyone could give me some good tutto on smtp's how they work ... and how to configure those values for the phpmailer ,i would really appreciate it.
    thanks advanced.

  2. #2
    Join Date
    Aug 2012
    Posts
    15
    Hi there, you can try to debug phpmailer to see if the problem is in the authentication:

    Try this at the end of your script:

    $mail->SMTPDebug = 1; // this will show the errors and messages

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles