Results 1 to 4 of 4

Thread: [RESOLVED] phpmailer problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Resolved [RESOLVED] phpmailer problem

    i'm trying to configure gmail to send mails with using phpmailer and i'm getting an error:

    Code:
    Could not execute: /var/qmail/bin/sendmail

    my code :

    PHP Code:
    <?php
    /**
    * Simple example script using PHPMailer with exceptions enabled
    * @package phpmailer
    * @version $Id$
    */

    require '../class.phpmailer.php';

    try {
        
    $mail = new PHPMailer(true); //New instance, with exceptions enabled

        
    $body             file_get_contents('contents.html');
        
    $body             preg_replace('/\\\\/',''$body); //Strip backslashes

        
    $mail->IsSMTP();                           // tell the class to use SMTP
        
    $mail->SMTPAuth   true;                  // enable SMTP authentication
        
    $mail->Port       25;                    // set the SMTP server port
        
    $mail->Host       "mail.google.com";     // SMTP server
        
    $mail->Username   "[email protected]";  // SMTP server username
        
    $mail->Password   "password";            // SMTP server password

        
    $mail->IsSendmail();  // tell the class to use Sendmail

        
    $mail->AddReplyTo("[email protected]","Test");

        
    $mail->From       "[email protected]";
        
    $mail->FromName   "test";

        
    $to "[email protected]";

        
    $mail->AddAddress($to);

        
    $mail->Subject  "First PHPMailer Message";

        
    $mail->AltBody    "To view the message, please use an HTML compatible email viewer!"// optional, comment out and test
        
    $mail->WordWrap   80// set word wrap

        
    $mail->MsgHTML($body);

        
    $mail->IsHTML(true); // send as HTML

        
    $mail->Send();
        echo 
    'Message has been sent.';
    } catch (
    phpmailerException $e) {
        echo 
    $e->errorMessage();
    }
    ?>
    could someone please give me some detailed information on how to fix this? i can't really find anything useful searching with google..

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: phpmailer problem

    GMail requires the use of SSL, as far as I know. You can check this out and see if it works for you. It has a patch for PHPmailer that enables the use of SSL.
    Like Archer? Check out some Sterling Archer quotes.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Re: phpmailer problem

    i'm sorry kows, i forgot to mention i used version 5 so that was all programmed into the class, and a whole lot more

    i deleted this line of the code
    Code:
    	$mail->IsSendmail();  // tell the class to use Sendmail
    then i got another error which said it could not authenticate so i did some searching and found that i had to replace and add some more code..

    Code:
    $mail->Mailer = "smtp";
    $mail->Port = 465;
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->SMTPSecure = "ssl";
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->SMTPKeepAlive = true;
    and i officially sent my first mail from localhost thanks&#180;


    also smtp.gmail.com was the smtp host.
    Last edited by Justa Lol; Feb 14th, 2011 at 10:23 AM.

  4. #4
    New Member
    Join Date
    Jun 2012
    Posts
    1

    Re: phpmailer problem

    hi Justa,
    i have same problem... I followed all these guidelines but one error
    "SMTP Error: Could not connect to SMTP host."
    Please help me...how to solve this error?

Posting Permissions

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



Click Here to Expand Forum to Full Width