#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    28
    Rep Power
    0

    Send mail via smtp


    Hi,

    I have been using php mailer class to send mail via smtp. I am using my gmail account info

    Here is the code:
    Code:
      
                        $mail = new PHPMailer();           
                        $mail->IsSMTP();
                        $mail->Mailer = "smtp";
                        $mail->SMTPDebug   =    0;  
                        $mail->Host        =    "smtp.gmail.com";
                        $mail->SMTPAuth    =    true;    
                        $mail->SMTPSecure  =    "ssl";
                        $mail->Port        =    456;
                        $mail->Username    =    'gmail id';   
                        $mail->Password    =    'my password';
                        $mail->SetFrom('email from id ', 'name');
                        $mail->Subject     =     "Email Verification";
                        $mail->Body        =     'Dear '.$_GET['Name']
                        $mail->AddAddress('test@yahoo.com',$_GET['Name']);
                        $mail->AddReplyTo('admin mail',"Admin");
                        $mail->IsHTML(true);
                        //$mail->ErrorInfo
                        if(!$mail->Send())
                           $error_mail =  "Mailer Error: ".$mail->ErrorInfo ;
                        else
                            $error_mail =  "Message has been sent";
    It always gives me error

    SMTP Connect() failed

    I have also enabled open ssl extension and uncommented from php.ini. Have also changed the port to 25 but it didnt work. I dont know where the actual problem is??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    Port 25 is almost invariably blocked by ISPs so that won't work. However, where did you get port 456? Port 857 (submission) is what gmail and most other SMTP servers use.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by gw1500se
    Port 25 is almost invariably blocked by ISPs so that won't work. However, where did you get port 456? Port 857 (submission) is what gmail and most other SMTP servers use.
    Even then it didnt work
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    Its my guess that either your credentials are wrong or the connection need to use STARTTLS not SSL.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by gw1500se
    Its my guess that either your credentials are wrong or the connection need to use STARTTLS not SSL.
    I have got it worked by using own smtp configuration and TLS. But i am getting error

    Mailer Error: SMTP Error: Data not accepted.<p>SMTP server error: Message rejected: Email address is not verified.

    I am using php5.3.13

    I dont know what is causing this problem
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    Yep. You have to verify all email addresses with gmail. The gmail web site explains it.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by gw1500se
    Yep. You have to verify all email addresses with gmail. The gmail web site explains it.
    why specifically with gmail?? i am no longer using gmail configuration
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    You set your host parameter to smtp.gmail.com. However, almost of the free smtp providers will require something similar.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    Sydney Australia
    Posts
    189
    Rep Power
    84
    Originally Posted by gw1500se
    Port 857 (submission) .
    Ummm. Port 587 is submission. 857 is not a Well Known Port.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    Sorry, that was a typo. I guess I'm slightly dyslexic sometimes.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo