Probably someone can see what I'm doing wrong here. When I use ->from('test#example.com') the mail sends just fine. But when i use >from('test#hotmail.com') the mail is not sent. Everything is done in mail configuration as well.
$data = array("content" => Input::get("content"));
Mail::send("emails.text", $data, function($message)
{
$message->to('toMe#myDomain.com')
->from('test#hotmail.com' , 'Contact form message!');
});
Config:
'driver' => 'smtp',
'host' => 'mail.cornex.se',
'port' => 587,
'from' => array('address' => "christopher#cornex.se", 'name' => "Kristoffer"),
'encryption' => 'tls',
Hotmail uses Outlook SMTP. Try this:You may need to make slight modifications, but make note of the host, specifically.
'driver' => 'smtp',
'host' => 'smtp-mail.outlook.com',
'from' => array('address' => "christopher#cornex.se", 'name' => "Kristoffer")
'port' => 587, // or 25
'encryption' => 'tls',
Related
I wanted to ask about sending emails in cakephp3.
I am using cakephp3 docs, and configured everything as example shows.
But, when I try to send mail, this error appears:
Could not send email: unknown
//app.php
'EmailTransport' => [
'default' => [
'className' => 'Mail',
// The following keys are used in SMTP transports
'host' => 'smtp.gmail.om',
'port' => 465,
'timeout' => 30,
'username' => 'mymail#gmail.com',
'password' => 'password',
'client' => null,
'tls' => null,
],
],
ContactController:
public function contact() {
if (isset($this->request->data) AND ($this->request->is('post'))) {
$email = new Email('default');
if ($email->from(['mymail#gmail.com' => 'My Site'])->to('othermail#gmail.com')->subject('Hello')->send('Message')) {
//pr( 'ok');
}
}
}
Is this a generic error message (, which may have many reasons, in my opinion)? it has no value in context of debug.
You want to use an SMTP server, but you've configured to use the Mail transport!
The className option should be set to Smtp. The host should probably also be different (ssl:// prefixed), or you should enable TLS, please be sure that you read through the questions/answers found with the search linked below.
See also
Cookbook > Email > Configuring Transports
https://stackoverflow.com/search?q=[cakephp]+gmail
The host name in default configuration is incorrect.
it should be
'host' => 'smtp.gmail.com',
instead of
'host' => 'smtp.gmail.om',
One thing that's always forgotten is the Email profiles
`'Email' => [
'default' => [
'transport' => 'gmail', //this allows the email class to use the gmail settings
'from' => 'youremail#gmail.com',
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
],`
And by the way you can set up multiple profiles for the like testing, development etc
use Cake\Mailer\Email;
Email::configTransport('gmail', [
'host' => 'smtp.gmail.com',
'port' => 587,
'username' => 'my#gmail.com',
'password' => 'secret',
'className' => 'Smtp',
'tls' => true
]);
Yous this code : Replace My#gmail.com and Secret with you credentials offcourse and after that use you code it will work.
I have tried this.
<?php
return array(
'driver' => 'smtp',
'host' => 'smtp.sendgrid.net',
'port' => 587,
'from' => array('address' => 'from#example.com', 'name' => 'John Smith'),
'encryption' => 'tls',
'username' => 'sendgrid_username',
'password' => 'sendgrid_password',
);
Mail::send('emails.demo', $data, function($message)
{
$message->to('jane#example.com', 'Jane Doe')->subject('This is a demo!');
});
But i am getting this error:
Failed to authenticate on SMTP server with username "sendgrid_username" using 2 possible authenticators
How to resolve this problem.
Please help me.
Make sure the settings are OK, username and password are correct, the function itself should work as you posted.
I configured my website to send mails through gmail's SMTP. My websiite is running in laravel - 4 framework. Below is the code in config>>mail.php
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => null, 'name' => null),
'encryption' => 'tls',
'username' => 'xxx#somedomain.com',
'password' => 'xxxxxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false
And this is a sample of code, on how I send mail,
$from = 'sender#somedomain.com';
$mail = Mail::send('mailer_template', ['any_data' => $data], function ($msg) use ($from, $from_name, $to_email, $subject, $attach) {
$msg->from($from,$from_name);
$msg->to($to_email);
$msg->subject($subject);
$msg->attach($attach);
});
When I send a mail, the mail is being sent. But it is sent from - 'xxx#somedomain.com'. I want it to be sent through the email in $from variabble. And the from address will change at different places. I am not sure how to configure this. Any help would be appreciated.
Have you visited this URL yet? If not, go there and follow the instructions then try to sign in again with your application on the production server.
https://accounts.google.com/displayunlockcaptcha
Try to solve it this way. Keep it mind.
Here password is not mandatory.
Keep blank for encryption field.
use smtp-relay.gmail.com.
return array(
'driver' => 'smtp',
'host' => 'smtp-relay.gmail.com',
'port' => 25, //25, 465 or 587
'from' => array('address' => 'xxx#gmail.com', 'name' => 'myname'),
'encryption' => '',
'username' => 'xxx#gmail.com',
'password' => '',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
This doesn't seems feasible as SMTP(gmail) only use one from email (whose detials are added to config/env).In your case whenever you send a mail, the mail is being sent from - 'xxx#somedomain.com'.
Start working with Laravel 4.2 I tried to send email using Gmail STMP server. Below is my app/config/mail.php.
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'sample_address#gmail.com', 'name' => 'Sample'),
'encryption' => 'tls',
'username' => 'sample_address#gmail.com',
'password' => 'sample password',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
Below is my php code.
<!-- app/views/emails/welcome.php -->
Mail::send('emails.welcome', 'Laravel Admin', function($msg) {
$msg->from('sample_address#gmail.com', 'Laravel Admin');
$msg->to('sample_receiver#gmail.com');
});
But it does not work. I have already configured my XAMPP php.ini on my MAC OSX. It only works when sending a normal PHP mail, not SMTP. The error message that I've got from Laravel on the view page is 'Error in exception handler'. I would like to see more error information but I don't know how to get more info. What is wrong with my code? What else do I need to do or configure? Thank you!
you can put your email and name in Input
Input::merge(array('email'=>'sample_receiver#gmail.com','name'=>'sample_name'));
Mail::send('emails.welcome', 'Laravel Admin', function($msg) {
$msg->from('sample_address#gmail.com', 'Laravel Admin');
$msg->to(Input::get('email'), Input::get('name'))->subject('You have');
});
also change 'encryption'
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'sample_address#gmail.com', 'name' => 'Sample'),
'encryption' => 'ssl',
'username' => 'sample_address#gmail.com',
'password' => 'sample password',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
You should change 'encryption' for ssl and in your gmail must be enabled IMAP access in config
When you are having problems with sending mails via gmail, try this. It worked for me.
Login with your gmail account and then go to:
https://accounts.google.com/b/0/DisplayUnlockCaptcha
and click continue. Then, you have few minutes to send your mail with your code.
After this, Google will allow sign in to that account from the new source.
Hi I just uploaded a site and am getting this error with the mail service.
Connection could not be established with host smtp.gmail.com [Connection refused #111]
This are my settings in my mail.php file.
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => array('address' => 'info#thesite.com', 'name' => 'Company Name'),
'encryption' => 'tls',
'username' => '*******',
'password' => '********',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
This works perfectly locally on my system but when i upload it live, it gives me errors, please help am at the verge of delivering a project, thanks!
I also faced same problem. As for me I had changed my SMPT configuring to port 25 (with SSL) and it's was fine.
I got my solution from google, you can see at here.
Try googlemail server with ssl encryption
return array(
'driver' => 'smtp',
'host' => 'smtp.googlemail.com',
'port' => 465,
'from' => array('address' => 'info#thesite.com', 'name' => 'Company Name'),
'encryption' => 'ssl',
'username' => '*******',
'password' => '********',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
Found the answer to the problem, was from my web host service providers, i use shared host so i had to call them to configure my account with them to be able to send out email, hope this helps anyone who has such problems like me in the future and this is a proper smtp configuration for gmail.
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'info#thesite.com', 'name' => 'Company Name'),
'encryption' => 'ssl',
'username' => '*******',
'password' => '********',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
Try changing these.
'driver' => 'mail',
'port' => 587,
'encryption' => 'ssl',
This configuration works for me in GoDaddy server.
be sure you google authentication settings are enabled:
https://www.google.com/settings/security/lesssecureapps
change driver smtp to sendmail.it worked for me
MAIL_DRIVER=sendmail