I have an issue regarding smtp using codeigniter email library. It works fine with smtp.gmail.com but I have to use vpn in this case. I found other solutions like smtp.exmail.qq.com, smtp.mail.yahoo.com or smtp.sina.com but when you send the form typing your email in email field its being sent only with the email you provided in smtp user. Further please look at my code and screen shotenter image description here:
//get the form data
$name = $this->input->post('name');
$from_email = $this->input->post('email');
$subject = $this->input->post('subject');
$message = $this->input->post('message');
//set to_email id to which you want to receive mails
$to_email =
'info#sample.com';
//configure email settings
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.exmail.qq.com';
//'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'myemail#exmail.qq.com';
$config['smtp_pass'] = 'my password';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes
//$this->load->library('email', $config);
$this->email->initialize($config);
//send mail
$this->email->from($from_email, $name);
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($message);
Related
Following is given the code, need help. I have the Goddady server, but I am not able to send mail.
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['SMTP_Secure'] = 'ssl';
$config['smtp_server'] = 'relay-hosting.secureserver.net'; //smtp.gmail.com
$config['smtp_host'] = 'smtp.gmail.com'; //smtp.gmail.com
$config['smtp_port'] = '465'
$config['smtp_user'] = '....#gmail.com';
$config['smtp_pass'] = '******';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'text'; // or html
$config['validation'] = true; // bool whether to validate email or not
$this->email->initialize($config);
$this->email->from('....#gmail.com', 'sender_name');
$this->email->to('....#gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.'); if($this->email->send())
{
echo "Working"; echo $this->email->print_debugger();}else{echo "Not working";
}
Please see my email sending code below and it is showing the following error while sending the email..
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
My Controller:
$from_email= "******";
$to_email = 'dummy#dummy.com';
$subject='Password Reset Request';
$htmlContent = '<p>'.$link.'</p>';
$this->load->library('email');
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from($from_email,'*****');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($htmlContent);
$this->email->send();
This condition is showing the above error. Actually, it was working fine initially in development stage, but now it is not..What could have gone wrong in this query...Thank you in advance..
you're using $this->email->initialize($config); but there is no actual configs on your code. And as per your error Unable to send email using PHP mail(), your server can run through sendmail.
Email Class in codeingiter
Example
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
To check outgoing mail with this on server
telnet google.com 25 # 587 or 2095 ,2096
Most server outgoing ports will be 25 or 587
if you are in localhost the code work, are you in live server ?
if your URL is siteurl.domain then try ,
$from_email= "email#siteurl.domain"; //from email must be from same server url
$to_email = 'dummy#dummy.com';
$subject='Password Reset Request';
$htmlContent = '<p>'.$link.'</p>';
//{INCLUDE SMTP CONFIG HERE IF THIS NOT WORKiNG THIS METHOD}
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes
$this->email->initialize($config);
$this->email->from('$from_email', 'sender name');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($htmlContent);
$this->email->send();
else try with SMTP:),
//SMTP CONFIG
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com'; //smtp host name
$config['smtp_port'] = '465'; //smtp port number
$config['smtp_user'] = 'ji******#gmail.com';
$config['smtp_pass'] = '*******'; //$from_email password
//Continue above code
I'm not able to comment(sorry) :),
sometimes SMTP method not working with Bluehost account :(
I just set up google mx records for my domain. When i use my normal gmail account, emails are sent but when I use my gsuite account, the mails are not sent. I am hosting my site on siteground. However I can receive emails from other email accounts on my gsuite account.
$this->load->library('email');
$subject = 'Subject';
$message = 'My message';
//configure email settings
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465
$config['smtp_user'] = 'info#mydomain.com';
$config['smtp_pass'] = 'my_password';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes
$config['validation'] = TRUE;
$this->email->initialize($config);
//send mail
$this->email->from('info#mydomain.com', 'MyDomainName');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($message);
//echo json_encode($this->email->print_debugger());
if($this->email->send())
return true;
else
return false;
You didn't attach any error message, but since it's working for your other Gmail accounts, try checking if turning on access to "less secure apps" for this account solves this issue and report back.
https://myaccount.google.com/lesssecureapps
(Don't forget to choose the right account, if you're logged in to several ones).
I had similar problem, I had to create a App Password to work (details here: https://support.google.com/accounts/answer/185833?hl=en)
Once the App Password was created I used:
$subject = 'Your subject';
$message = 'Your body';
//configure email settings
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'your#email.com';
$config['smtp_pass'] = 'your app password';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes
$config['validation'] = TRUE;
$this->email->initialize($config);
//send mail
$this->email->from('from#email', 'Title');
$this->email->to('to#email.com');
$this->email->subject($subject);
$this->email->message($message);
I will make mail delivery system using PHP CodeIgniter. Email successfully submitted, but when I check my email, the sender mail is my smtp_user, not the real email sender.
for example: My smtp_user is a#gmail.com. When user send mail to me, sender mail is a#gmail.com, not user#gmail.com.
Here is my code in email.php :
$config['wordwrap'] = TRUE;
$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.gmail.com";
$config['smtp_port'] = "465";
$config['smtp_user'] = "a#gmail.com";
$config['smtp_pass'] = "blablabla";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['priority'] = "1";
$config['newline'] = "\r\n";
And here is my controller :
$this->load->library('email');
$link=base_url()."verification/".$verification_code."";
$body="Thanks for joining <br> Your code verification is
<a href=".$link." target='_blank'>".$link."</a>";
$this->email->from($this->input->post('mails'), strtoupper($name));
$this->email->to('b#gmail.com');
$this->email->subject('New account registration');
$this->email->message($body);
$this->email->send());
What's wrong with my config email?
but if I using smtp_host with mandrillapp, I did'nt see the problem like above.
I am using codeigniter for sending mail directly..
How to get send main in my mail account using codeigniter mailer?
my Code:
$ci = get_instance();
$ci->load->library('email');
$config['useragent'] = "Codeigniter";
$config['protocol'] = "smtp";
$config['smtp_host'] = "mail.example.com";
$config['smtp_port'] = "25";
$config['smtp_user'] = "account#example.com";
$config['smtp_pass'] = "Password";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$ci->email->initialize($config);
$ci->email->from('account#example.com', 'Account');
$list = array($email);
$ci->email->to($list);
$this->email->reply_to('account#example.com', 'Account');
$ci->email->subject('Verify your Email');
$ci->email->message('Massge body contain');
$ci->email->send();
I want to get all send email in account#example.com send mail box. it is possible?
add cc or bcc your email account better bcc
$this->email->cc('account#example');
or
$this->email->bcc('account#example');