$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp_host';
$config['smtp_port'] = 25;
$config['smtp_user'] = 'smtp_user';
$config['smtp_pass'] = '$$$';
$this->load->library('email', $config);
$this->email->initialize($config);
$this->email->from($config['smtp_user']);
$this->email->to('aaaa#test.com');
$this->email->subject('TEST MAIL');
$this->email->message('TESTING OF MAIL');
if ($this->email->send()) {
return true;
} else {
return false;
}
This is my code for sending email. I got below error.
Message: fsockopen(): unable to connect to box334.bluehost.com:25 (A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed
because connected host has failed to respond. )
You email server is not responding properly. try to check your email server setting like smtp PORT, SMTP HOST and USER etc.
Related
my codeigniter framework wont send emails by smtp. I always return a error that he cannot send the my by smtp over php on this server. If i check my username, host and password by copy and past to login with a webclient into the mailbox, it workds. So i use the correct host, username and password.
I think i have setup something wrong, but i dont know what.
Thats the email_helper
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "smtp";
$config['smtp_host'] = $settings['smtp_host']; (smtp.domain.com)
$config['smtp_port'] = $settings['smtp_port']; (465)
$config['smtp_timeout'] = '30';
$config['smtp_user'] = $settings['smtp_user']; (email = user)
$config['smtp_pass'] = $settings['smtp_pass']; (my password)
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = TRUE;
$controller->load->library('email');
$controller->email->initialize($config);
$controller->email->from( $settings['email_from'] , $settings['application_name'] );
$controller->email->to($to);
$controller->email->subject($subject);
$controller->email->message($body);
if($cc != '')
{
$controller->email->cc($cc);
}
if($attachment != '')
{
$controller->email->attach(base_url()."your_file_path/" .$attachment);
}
if($controller->email->send()){
return "success";
}
else
{
echo $controller->email->print_debugger();
}
}
I've chekced the correct values from the $settings array, too.
To send the email i do it in this way
$this->mailer->mail_template($to,'forget-password',$mail_data);
Adding the ssl information solved the problem
$config['smtp_crypto'] = 'ssl';
I have a problem with PHPMailer inside my Windows Server 2012. I'm using XAMPP as my local server. I notice that i cannot ping smtp.gmail.com in my window server 2012. it says
ping request could not find host smtp.gmail.com. Please check and try again
I added this line in php.ini
[mail function]
smtp_server=smtp.gmail.com
smtp_port=25
sendmail_path ="\"D:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=On
And I added this line in sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username=example#gmail.com
auth_password=password
force_sender=
force_recipient=
hostname=localhost
I test my PHPMailer in my local PC, it works fine. I can send into my own domain email ("example#pn.com") and other domain email such as test#gmail.com, test#yahoo.com etc. Here's my PHPMailer code.
testsend.php
<?php
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "example#gmail.com";
$mail->Password = "password";
$mail->setFrom('test#gmail.com', 'First Last');
//$mail->addReplyTo('replyto#example.com', 'First Last');
$mail->addAddress('test#gmail.com', 'John Doe');
$mail->Subject = 'PHPMailer GMail SMTP test';
//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->Body = 'dfssf';
$mail->AltBody = 'This is a plain-text message body';
//$mail->addAttachment('images/phpmailer_mini.png');
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
But when I add similar PHPMailer folder and files inside my server, it only work when I send to my own domain which is ("example#pn.com").It does not work with other email domain such as gmail, yahoo etc. It says
Mailer Error: SMTP Error: The following recipients failed: test#gmail.com: Unable to relay
How to fix that problem ?
Thanks.
i have a simple config email for send an email.
$this->load->library('email');
$config['smtp_crypto'] = 'tls';
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = 587;
$config['smtp_timeout'] = '5';
$config['smtp_user'] = 'hi*****y#gmail.com';
$config['smtp_pass'] = '*****';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html'; // or html
// $config['validation'] = TRUE; // bool whether to validate email or not
$this->email->initialize($config);
$message = "content";
$this->email->from("hikmatfauzy#gmail.com", "judul");
$this->email->to("hikmatfauzy7#gmail.com");
$this->email->subject("judul");
$this->email->message($message);
$this->email->send();
echo $this->email->print_debugger();
I get this error message below. how can i do?
i tried on my xampp server but running well. but on IIS i got this error.
A PHP Error was encountered
Severity: Warning
Message: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Filename: libraries/Email.php
Line Number: 1703
NOTE:
I changed $config['smtp_port'] from 465/587/25 (still got the
error).
I changed my php.ini openssl extension (still got the
error).
i am using php mailer in Codeigniter.
here is my email settings
mail was sending to other email id but not sending to email id which is in office 365.
<?php defined('BASEPATH') OR exit('No direct script access allowed.');
$config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_user'] = 'example#example.com';
$config['smtp_pass'] = 'password';
//$config['smtp_port'] = 587;
$config['smtp_timeout'] = 5; // (in seconds)
$config['smtp_crypto'] = 'tls'; // '' or 'tls' or 'ssl'
$config['smtp_debug'] = 4; // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.
$config['wordwrap'] = true;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html'; // 'text' or 'html'
$config['charset'] = 'ISO-8859-15'; // 'UTF-8', 'ISO-8859-15', ...; NULL (preferable) means config_item('charset'), i.e. the character set of the site.
$config['validate'] = true;
$config['priority'] = 3; // 1, 2, 3, 4, 5; on PHPMailer useragent NULL is a possible option, it means that X-priority header is not set at all, see https://github.com/PHPMailer/PHPMailer/issues/449
$config['crlf'] = "\n"; // "\r\n" or "\n" or "\r"
$config['newline'] = "\n"; // "\r\n" or "\n" or "\r"
$config['bcc_batch_mode'] = false;
$config['bcc_batch_size'] = 200;
$config['encoding'] = '8bit'; // The body encoding. For CodeIgniter: '8bit' or '7bit'. For PHPMailer: '8bit', '7bit', 'binary', 'base64', or 'quoted-printable'.
i have the following error
Connection: opening to smtp.office365.com:25, timeout=5, options=array ( ) 2016-01-02 10:00:49 SMTP ERROR: Failed to connect to server: Connection refused (111) 2016-01-02 10:00:49 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting bool(false)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
same setting are working in other servers, but not working in Go daddy server.
i checked openssl connection was enabled.
There are many duplicates of this question, and it's also covered in the PHPMailer docs: GoDaddy blocks outbound email, so you have to use their mail servers.
Mandrill working fine in my localhost, but not on server. The following SMTP error was encountered: 110 Connection timed out.I'm working in codeigniter.
Here's my email config file :
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['priority'] = 1;
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.mandrillapp.com';
$config['smtp_port'] = '587';
$config['smtp_user'] = 'abcdefgh#gmail.com';
$config['smtp_pass'] = 'xxxxxxxxxxxxxxxxxxxxxx';
The mails are received wen sending from localhost. I tried debugger.and i receive the above error. Please help!!! What could be the reason??
i think the port is blocked, try this in any controller:
$connection = #fsockopen('smtp.mandrillapp.com', 587);
if (is_resource($connection)){
echo 'open';
fclose($connection);
}else{
echo 'closed';
}
i've already had this problem while i'm implementing mandrill on my web app.