I have a problem sending a registration email via zend_mail. The mail is transmitted only to mails that have a #gmail.com.
$email = "test#gmx.net";
$mail = new Zend_Mail ();
$mail->setBodyText ( 'some text' );
$mail->setBodyHtml ( 'some text' );
$mail->setFrom ( 'support#mysite.net', 'MySite.net' );
$mail->addTo ( $email, $email );
$mail->setSubject ( 'test' );
$mail->send ();
If the user has another email provider the email is not sent.
Any ideas?
I use smtp now and it works:
$config = array('auth' => 'login',
'username' => '****#gmail.com',
'password' => '****',
'port' => '25',
'ssl' => 'tls');
$transport = new Zend_Mail_Transport_Smtp('smtp.googlemail.com', $config);
Related
i want to get read receipt of emails that we send by codeigniter emails.
i am not able to get how to use it in codeigniter mails.
i know we should use X-confirm reading but its not working in codeigniter.
public function formcomplete()
{
$appid = $this->uri->segment(3);
$datan = $this->product->fetchtransaction($appid);
$txnid = $datan[0]['txn_id'];
$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',
);
$datanew = array(
'firstname' => $datan[0]['firstname'],
);
$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'] = $datanew;
$mesg = $this->load->view('email/reminder/form_complete',$data,true);
$this->email->to($email);
$this->email->AddCustomHeader( "X-Confirm-Reading-To: notifications#mymail.com" );
$this->email->from('support#mail.com','Company Email');
$this->email->subject($subject);
$this->email->message($mesg);
$this->email->send();
$baseurl = "https://www.getyourevisa.com/admin/application/view/";
$completeurl = $baseurl.$appid;
//redirect('admin/application/view/' . $appid);
echo ("<script LANGUAGE='JavaScript'>
window.alert('Form Complete Reminder Successfully Sent');
window.location.replace('$completeurl');
</script>");
}
i have used below line, but its not working, i think there should be some other way to write this code.
$this->email->AddCustomHeader( "X-Confirm-Reading-To: notifications#mymail.com" );
For CI version 3, it should be
$this->email->set_header('X-Confirm-Reading-To', 'name#email.com');
For CI version 4
$email->setHeader('X-Confirm-Reading-To', 'name#email.com');
I am working with CakePHP version 1.3.13.
Here, I want to send mail. So I have written code like this :
function send_mail_to_client()
{
$text = "sending mail";
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->from(array('sachingarala.v2047#gmail.com' => 'My Site'));
$Email->to('nisargbhavsar24#gmail.com');
$Email->subject('Test mail');
$Email->send($text);
}
But, mail is not send to the destination. So what is the wrong in this code?
How can I resolve this problem?
Add the configs after initialization i.e. $Email = new CakeEmail(); like
$Email->config(array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'my#gmail.com',
'password' => 'secret',
'transport' => 'Smtp'
);
My codeigniter script will not send emails. I have tested sendmail on xampp with a native PHP email script and it works. This is definitely a problem with CI or my config. The send() function always returns false and the print_debugger() function is always blank. Am I doing something wrong?
<?php
$config = array(
'mailtype' => 'html',
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_user' => 'myaccount#gmail.com',
'smtp_pass' => '#############',
'smtp_port' => '465'
);
$this->load->library('email', $config);
$this->email->from($this->stg['site_name']);
$this->email->to($this->input->post('email_address'));
$this->email->subject('Your Account Email Has Been Changed');
$data = array(
'activation_code' => $this->member->activation_code
);
$message = $this->load->view('emailTemplates/change_email', $data, true);
$this->email->message($message);
if(!$this->email->send()){
$this->template->overallHeader('Email Failed');
$data = array(
'title' => 'Email Sending Failed',
'message' => 'The system failed to dispatch the email message to your new email address. Because of this, the email address on your account has NOT been changed. '.$this->email->print_debugger()
);
$this->load->view('errorBody', $data);
} else {
//do stuff
}
I have also tried static strings instead of the form input variables as the to and from, etc.
I need to send two different emails one for the admin and the other email is a confirmation email for the user to confirm that we have received his request. I don't know how can I exactly send different emails to different email addresses in the same action in cakephp.
Code :
Controller
$Email = new CakeEmail('notifications');
$result = $Email->to(array('admin#example.com'))
->subject(__("Request Notification))
->send($message);
if($result){
$this->redirect('/pages/thankyou');
$companymsg= "Dear,Thank you for you interest we will contact you soon."
$Email = new CakeEmail('usernotifications');
$Email->to(array($email))
->subject(__(" Request"))
->send($companymsg);
}
Email Configuration
public $notifications = array(
'transport' => 'Mail',
'from' => array('notifications-noreply#example.com' => '(Notification)'),
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
'emailFormat' => 'html',
);
public $usernotifications = array(
'transport' => 'Mail',
'from' => array('no-reply#example.com' => 'My Project'),
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
'emailFormat' => 'html',
);
Try:
$Email = new CakeEmail('notifications');
$result = $Email->to(array('admin#example.com'))
->subject(__("Request Notification))
->send($message);
$companymsg= "Dear,Thank you for you interest we will contact you soon."
$Email = new CakeEmail('usernotifications');
$Email->to(array($email))
->subject(__(" Request"))
->send($companymsg);
$this->redirect('/pages/thankyou');
I am trying to send email by smtp options using zend/Mail
Here is my code:
//use the base class
use Zend\Mail;
use Zend\Mime\Part as MimePart;
use Zend\Mime\Message as MimeMessage;
and here is is my mail functionality code in controller
//mail functionality
$email = "xxxx#gmail.com";
$pas = "xxxx";
// setup SMTP options
$options = new Mail\Transport\SmtpOptions(array(
'name' => 'localhost',
'host' => 'smtp.gmail.com',
'port'=> 587,
'connection_class' => 'login',
'connection_config' => array(
'username' => $email,
'password' => $pas,
'ssl'=> 'tls',
),
));
$this->renderer = $this->getServiceLocator()->get('ViewRenderer');
$content = $this->renderer->render('patient-register/email/template', null);
// make a header as html
$html = new MimePart($content);
$html->type = "text/html";
$body = new MimeMessage();
$body->setParts(array($html,));
// instance mail
$mail = new Mail\Message();
$mail->setBody($body); // will generate our code html from template.phtml
$mail->setFrom('xxxx#xxxx.com','mub');
$mail->setTo('xxxx#gmail.com');
$mail->setSubject('TESTING THE EMAIL ACCCOUNT');
$transport = new Mail\Transport\Smtp($options);
$transport->send($mail);
So when i try to send mail from my localhost, its get sucess
But when i try to send the email from the remote server, 128.199.123.145 and the server is a centos server from digitalocean.
Is that anything to change in remote server.
Thanks,