[英]CakePHP Cake Email SMTP Gmail
I have a problem with getting Cake Email to work properly. 我无法使Cake Email正常工作。 I set everything up exacly as specified in cookbook ( http://book.cakephp.org/2.0/en/core-utility-libraries/email.html section 'Configuration').
我完全按照食谱( http://book.cakephp.org/2.0/en/core-utility-libraries/email.html “配置”部分)中的说明进行了所有设置。 When I test it on localhost (xampp) everything works like a charm, the problem is, when I upload files on my web server, and try to execute it (send email) I get "Network is unreachable".
当我在本地主机(xampp)上对其进行测试时,所有内容都可以正常运行,问题是,当我在Web服务器上上传文件并尝试执行它(发送电子邮件)时,我得到“网络无法访问”。 It seems to me, that there is probably some issue on server-side, but what could that be, and how to fix that?
在我看来,服务器端可能存在一些问题,但是那可能是什么,以及如何解决该问题? Thanks in advance.
提前致谢。
EDIT: My code, as requested. 编辑:我的代码,按要求。
/app/Config/email.php /app/Config/email.php
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'wykresl***14@gmail.com',
'password' => '***********',
'transport' => 'Smtp',
'timeout' => '30'
);
in Controller 在控制器中
public function test()
{
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail('gmail');
$Email->from(array('wykreslanka.2014@gmail.com' => 'Wykreślanka 2014'));
$Email->to('si***1@gmail.com');
$Email->subject('test');
$Email->template('newsletter');
$Email->emailFormat('html');
$Email->viewVars(array('post_id'=>0,'post_title'=>'Tytuł','post_body'=>'Body','quote_is'=>false));
$Email->send();
$this->Session->setFlash('Poszło','success');
return $this->redirect(array('action' => 'all'));
}
Typically, most web hosting services block external SMTP connections for some reason I'm still trying to understand. 通常,大多数Web托管服务出于某些我仍试图理解的原因会阻止外部SMTP连接。 One such webhost I know is JustHost.
我知道的一种这样的虚拟主机是JustHost。
They want you to use their local smtp server... I would suggest you get in contact with your webhosting service a I'm 100% sure its something on their part and not with your code. 他们希望您使用他们的本地smtp服务器...我建议您与您的虚拟主机服务联系,我100%确信他们的事情与您的代码无关。
My webhost refused to listen so the best alternative I used was MailGun http://www.mailgun.com/ This allows you to send an email using an php-api that they provide. 我的虚拟主机拒绝听,所以我使用的最好的替代方法是MailGun http://www.mailgun.com/。这使您可以使用他们提供的php-api发送电子邮件。 However you wont be able to use your gmail address.
但是,您将无法使用自己的Gmail地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.