Need Help to Send PHP mail via SMTP

Discussion in 'PHP' started by dmssrinivas, Nov 5, 2009.

  1. #1
    I am using bbpress for my forums site. I have free hosting service for this at some host.

    The problem is that, sending a mail from my forums to users take very long, up to 20 minutes. This is due to the free hosting service I am using as said by the support. And gmail SMTP is recommended for better results.

    Now I want to send mails via Gmail SMTP to the users so that it would reach faster. But how is the question.

    For a check, I created the page shown below, but even that won't send any mail to the set destination.

    <?php
    require('/bb-includes/backpress/class.mailer.php');
    
    $mail = new PHPMailer();
    
    $mail->IsSMTP();                     // send via SMTP
    $mail->Host     = "ssl://smtp.gmail.com:465"; // SMTP servers
    $mail->SMTPAuth = true;     // turn on SMTP authentication
    $mail->Username = "****@****.net";  // SMTP username
    $mail->Password = "******"; // SMTP password
    $mail->SMTPDebug = true;
    
    
    $mail->From = '****@****.net';
    $mail->FromName = '***** Forums';
    
    $mail->Subject  =  "Here is the subject";
    $mail->Body     =  "This is the <b>HTML body</b>";
    $mail->AltBody  =  "This is the text-only body";
    
    if(!$mail->Send())
    {
       echo "Message was not sent <p>";
       echo "Mailer Error: " . $mail->ErrorInfo;
       exit;
    }
    
    echo "Message has been sent";
    ?>
    PHP:
     
    dmssrinivas, Nov 5, 2009 IP
  2. Stephie

    Stephie Peon

    Messages:
    133
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    why is there ssl in front of host I think it's supposed to be smtp.gmail.com
     
    Stephie, Nov 6, 2009 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375