$config = [
'protocol' => 'sendmail',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_user' => '***************',
'smtp_pass' => '********',
'smtp_port' => 465,
'smtp_timeout' => '30',
'mailtype' => 'html',
// 'ssl' => [
// 'verify_peer' => false,
// 'veriry_peer_name' => false,
// 'allow_self_sign' => true
// ],// ini hanya jika jaringa tidak ssl/https, jangan dilakukan di produksi
'starttls' => true,
'charset' => 'utf-8',
'newline' => "\r\n"
];
Hi All, I have
I have tried to send mail from my local host but it return error like bellow,
Message: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream
Thank you for your help,
for sending mail from local i'm using SMTP. Please change your code with following code. It's working for me. Do not edit system file. That will create problem for you in future.
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = '********'; //your email id
$config['smtp_pass'] = '********'; //email id password
$config['smtp_port'] = 465;
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;
Related
i need to send emails to all the rows in database table with their corresponsing data. i am able to send single emails by their id, but now i need to send in bulk. i have done in pure php but in codeigniter not able to figure out. how to do this.
my controller is
public function autoformcomplete()
{
$this->load->model('admin/Reminder_model');
$datan = $this->Reminder_model->autoformemail();
//this should be in whileloop, that i am not able to figure out
$email = $datan[0]['email'];
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'email-smtp.eu-west-1.amazonaws.com',
'smtp_port' => 587,
'smtp_crypto' => 'tls',
'smtp_user' => 'user',
'smtp_pass' => 'pass',
'mailtype' => 'text',
'charset' => 'utf-8',
);
$this->email->initialize($config);
$this->email->set_mailtype("html");
$this->email->set_newline("\r\n");
$this->email->set_crlf("\r\n");
$subject = "Complete Your Partially Filled Application-".$appid."";
$data['datan'] = $datan;
$mesg = $this->load->view('email/reminder/form_complete',$data,true);
$this->email->to($email);
$this->email->from('mail#mail.com','My Company');
$this->email->subject($subject);
$this->email->message($mesg);
$this->email->send();
echo "sent";
}
My Model is
public function autoformemail(){
$this->db->order_by('id', 'DESC');
$query = $this->db->get('appstbldata');
return $query->result_array();
}
Just use a foreach loop
public function autoformcomplete() {
$this->load->model( 'admin/Reminder_model' );
$datan = $this->Reminder_model->autoformemail();
foreach ( $datan as $index => $val ) {
// $val now references the current pointer to an element in your $datan array
$email = $val['email'];
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'email-smtp.eu-west-1.amazonaws.com',
'smtp_port' => 587,
'smtp_crypto' => 'tls',
'smtp_user' => 'user',
'smtp_pass' => 'pass',
'mailtype' => 'text',
'charset' => 'utf-8',
);
$this->email->initialize( $config );
$this->email->set_mailtype( "html" );
$this->email->set_newline( "\r\n" );
$this->email->set_crlf( "\r\n" );
$subject = "Complete Your Partially Filled Application-" . $appid . "";
$data['datan'] = $datan;
$mesg = $this->load->view( 'email/reminder/form_complete', $data, true );
$this->email->to( $email );
$this->email->from( 'mail#mail.com', 'My Company' );
$this->email->subject( $subject );
$this->email->message( $mesg );
$this->email->send();
echo "sent";
}
}
I dunno what your point of $data['datan'] = $datan; line is though
How can i upload my file to amazon in filemanager (responsive filemanager) and encrypt it once the image is uploaded.
when using this setup it only save all image on my local folder, any thoughts in this matter?
and when i change my 'curent_path' to 'https://s3-us-west-2.amazonaws.com/dir/subdir/directoryhere it give me error on php
below is my sample code setup,
if (!empty($_SERVER["SERVER_NAME"])) {
$host = $_SERVER["SERVER_NAME"];
} else {
$host = "localhost";
}
$urlParts = explode(".",$host);
$subdomain = $urlParts[1];
if ($subdomain == "tvms") {
$link = "https://s3.amazonaws.com";
$bucket = "tvms-live";
} else {
$link = "https://s3-us-west-2.amazonaws.com";
$bucket = "tvms-uat";
}
define('USE_ACCESS_KEYS', false); // TRUE or FALSE
define('DEBUG_ERROR_MESSAGE', true); // TRUE or FALSE
$config = array(
//'base_url' => ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"). "://". #$_SERVER['HTTP_HOST'],
'base_url' => $link,
'upload_dir' => '/' . $bucket . '/acvr/uploads/hostedimages/',
'current_path' => '../source/',
'thumbs_base_path' => '../thumbs/',
'mime_extension_rename' => true,
'ftp_host' => false, //put the FTP host
'ftp_user' => "user",
'ftp_pass' => "pass",
'ftp_base_folder' => "base_folder",
'ftp_base_url' => "http://site to ftp root",
// Directory where place files before to send to FTP with final /
'ftp_temp_folder' => "../temp/",
'ftp_thumbs_dir' => '/thumbs/',
'ftp_ssl' => false,
'ftp_port' => 21,
/* EXAMPLE
'ftp_host' => "host.com",
'ftp_user' => "test#host.com",
'ftp_pass' => "pass.1",
'ftp_base_folder' => "",
'ftp_base_url' => "http://host.com/testFTP",
*/
'multiple_selection' => true,
'multiple_selection_action_button' => true,
'access_keys' => array(
'key' =>'AAKJSKDFIOUEJKNRWELNQWEWQE',
'secret' => 'opisdfj2j3kl2n43249sdfijadsf890324'
),
heres the error message
Im new in phalcon want a working example of phpmailer that send email from my site. currently i just figure out like this. i just follow this link: github.com/asyamedya/phalcon-phpmailer.
[config.php]
$config = new Phalcon\Config(array(
"app" => array(
"controllersDir"=> "app/controllers/",
"modelsDir" => "app/models/",
"viewsDir" => "app/views/",
"pluginsDir" => "app/plugins/",
"libraryDir" => "app/library/",
"helpersDir" => "app/helpers/",
"formsDir" => "app/forms/",
"cacheDir" => "cache/volt/",
"logsDir" => "cache/logs/",
"encryptKey" => "",
"baseUri" => "/demo/",
"StaticBaseUri" => "http://localhost/demo/",
"debug" => '0',
),
"mail" => array(
"driver" => "smtp",
"host" => "smtp.gmail.co",
"username" => "2munax#gmail.com",
"password" => "*****",
"security" => "tls", //ssl:465, tls:587
"port" => 587,
"charset" => "UTF-8",
"email" => "2munax#gmail.com",
"name" => "webmaster",
),
));
[loader.php]
use Phalcon\Loader;
$loader = new Loader();
$loader->registerDirs(
array(
APP_PATH . $config->app->controllersDir,
APP_PATH . $config->app->modelsDir,
APP_PATH . $config->app->pluginsDir,
APP_PATH . $config->app->libraryDir,
APP_PATH . $config->app->helpersDir,
APP_PATH . $config->app->formsDir,
APP_PATH . $config->app->cacheDir,
)
)->register();
[service.php]
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\Mvc\Router;
use Phalcon\Security;
use \PHPMailer as PHPMailer;
use Phalcon\Mvc\View\Engine\Volt;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Flash\Session as FlashSession;
use Phalcon\Logger\Adapter\File as Logger;
use Phalcon\Mvc\Model\Metadata\Apc as ApcMetaData;
use Phalcon\Session\Adapter\Files as SessionAdapter;
require(APP_PATH . $config->app->libraryDir . 'PHPMailer/PHPMailerAutoload.php');
$di->set('pmailer', function() use ($config){
$pmailer = new PHPMailer();
//$mail->setLanguage('fr', '/optional/path/to/language/directory/');
$pmailer->isSMTP(true);
$pmailer->SMTPDebug = 2; // Enable verbose debug output
$pmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$pmailer->Charset = $config->mail->charset;
$pmailer->Host = $config->mail->host;
$pmailer->SMTPAuth = true;
$pmailer->Username = $config->mail->username;
$pmailer->Password = $config->mail->password;
$pmailer->SMTPSecure = $config->mail->security;
$pmailer->Port = $config->mail->port;
$pmailer->addAddress($config->mail->email,$config->mail->name);
$pmailer->isHTML(true);
return $pmailer;
});
[controller index]
public function SendmailAction()
{
$this->pmailer->From = "2munax#gmail.com";
$this->pmailer->FromName = "user";
$this->pmailer->addReplyTo("2munax#gmail.com", "user");
$this->pmailer->addAddress('babymachinery83#gmail.com');
$this->pmailer->Subject = "email test !";
$this->pmailer->Body = "success!";
$this->pmailer->WordWrap = 70;
if(!$this->pmailer->send()){echo 'Message could not be sent.';
echo 'Mailer Error: ' . $this->pmailer->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
In my library i have this files.
[Library/PHPMailer/]
class.phpmailer.php
class.pop3.php
class.smtp.php
PHPMailerAutoload.php
class.phpmaileroauthgoogle.php
I'm not sure, but you I think this is wrong in your service.php
use Phalcon\PHPMailer;
Change it to
use \PHPMailer as PHPMailer;
I am sending mail using smtp options. When I sent mail via ssl it is working fine. But when I tried to send mail via tls, it is not working properly.
My application is in CakePHP 1.3.
function testemail() {
$from = 'test#domain.com';
$this->Email->delivery='smtp';
$this->Email->smtpOptions = array(
'port'=>'portnumber',
'auth' => true,
'host' => 'tls://smpt.xxxx.com',
'username'=>'test#domain.com',
'password'=>'xxxxxxxxx',
);
$this->Email->to = 'xxxxxx#gmail.com';
$this->Email->subject = 'Test Email';
$this->Email->from = $from;
$this->Email->replyTo = $from;
$this->Email->return = $from;
$this->Email->additionalParams = '-f'.$from;
$this->Email->sendAs = 'html';
$this->Email->template = 'template';
$this->set('template','Testing TLS mail');
if($this->Email->send()) {
$this->Session->setFlash(__('Mail sent.', true));
} else {
$this->Session->setFlash(__('Error.', true));
}
}
Thanks
try this alternative if your server supports SSL:
'port' => '465',
'host' => 'ssl://smpt.xxxx.com',
I was wondering if there anyway to move this configuration from the INI into the bootstrap.php in a way it would be the default globally. If so, how should I do it? I'm with zend 1.11.
thanks in advance.
;resources.mail.transport.type = smtp
;resources.mail.transport.host = "smtp.gmail.com"
;resources.mail.transport.auth = login
;resources.mail.transport.ssl = ssl
;resources.mail.transport.port = 465
;resources.mail.transport.username = email#example.com
;resources.mail.transport.password = pass
;resources.mail.transport.register = true ; True by default
;resources.mail.defaultFrom.email = email#example.com
;resources.mail.defaultFrom.name = "Foo"
;resources.mail.defaultReplyTo.email = email#example.com
;resources.mail.defaultReplyTo.name = "Foo"
[SOLUTION]
Actually it worked for me adding:
$config = array(
'ssl' => $transport_ssl,
'port' => $transport_port,
'auth' => $transport_auth,
'username' => $transport_username,
'password' => $transport_password,
'register' => $transport_register,
);
$transport = new \Zend_Mail_Transport_Smtp($transport_host, $config);
// var_dump($transport);exit;
\Zend_Mail::setDefaultTransport($transport);