I have been trying to send email from my local host using PHPMailer but i cant fix this error
SMTP connect() failed.
I know there are suggestion for this kind of error but non i have tried seems to work for me. Here are my settings
$mail = new PHPMailer();
                $mail->IsSMTP(); // we are going to use SMTP
                $mail->Host       = 'smtp.gmail.com';      // setting GMail as our SMTP server
                $mail->SMTPAuth   = true; // enabled SMTP authentication
                $mail->Username   = 'mygamil';  // user email address
                $mail->Password   = "mypassword";            // password in GMail
                $mail->SMTPSecure = "tls";  // prefix for secure protocol to connect to the server
                $mail->SetFrom($this->session->userdata('email'), $this->session->userdata('username'));  //Who is sending the email
                $mail->AddReplyTo("[email protected]",$this->session->userdata('username'));  //email address that receives the response
                $mail->Subject    = $subject;
                $mail->Body       = $message;
                $mail->AltBody    = $message;
                $destino = "[email protected]"; // Who is addressed the email to
                $mail->AddAddress($destino, "Sender name");
                $mail->AddAttachment($file_path);      // some attached files/
                if($mail->Send() ==TRUE){
                    redirect('app/send/'.$this->uri->segment(3).'/succeeded ');
                }
                else
                {
                  //show an error email failed erroers 
                    $email_error = array('email_error'=>$mail->ErrorInfo);
                }
I have tried with port 587 and 465 none of them seems to work but when i telnet to either of the ports i get connections without error
I have openssll.dill enable in my php.ini
i have tried this settings both in MAMP in my mac and in Ubuntu 12.04 and still i get the same error
Any input would be appreciated thanks in advance
You need full email address in your connection configurations:
$mail->Username = '[email protected]';
And if use TLS security protocol you need use:
$mail->SMTPSecure = "tls";
$mail-> Port = 587;
...
Or to SSL (that is deprecated status):
$mail->SMTPSecure = "ssl";
$mail-> Port = 465;
...
Check your php.ini file, on it, if you have this:
;extension=php_openssl.dll
change it to
extension=php_openssl.dll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With