2015-11-01 80 views
2

我在用Codeigniter(PHP)編寫的Google App Engine上託管了一個Web應用程序。我使用sendgrid發送交易電子郵件。如何使用帶有Google App Engine的自定義域名(https)的Sendgrid發送電子郵件

該應用最初是託管在https://appid.appspot.com,一切都很好。

我最近將應用程序URL更改爲https://app.domain.com,並導入了我從godaddy購買的SSL證書。就ssl證書而言,我沒有任何問題。

但是,當發送交易電子郵件,我得到以下錯誤。爲我所用在https://app.appspot.com託管不同的應用程序相同的憑據

Severity: Warning 

Message: fsockopen(): php_network_getaddresses: gethostbyname failed. errno=0 

Filename: libraries/Email.php 

Line Number: 1949 

Backtrace: 

File: /base/data/home/apps/s~chutti-app-prod/1.388253899009796980/application/controllers/Signup.php 
Line: 60 
Function: send 

File: /base/data/home/apps/s~chutti-app-prod/1.388253899009796980/index.php 
Line: 292 
Function: require_once 

A PHP Error was encountered 

Severity: Warning 

Message: fsockopen(): unable to connect to smtp.sendgrid.net:587 (php_network_getaddresses: gethostbyname failed. errno=0) 

Filename: libraries/Email.php 

Line Number: 1949 

Backtrace: 

File: /base/data/home/apps/s~chutti-app-prod/1.388254166863409817/application/controllers/Signup.php 
Line: 60 
Function: send 

File: /base/data/home/apps/s~chutti-app-prod/1.388254166863409817/index.php 
Line: 292 
Function: require_once 

的sendgrid憑據是相同的,一切都很好。問題只在於我的自定義網址與https。發送電子郵件

$this->load->library('email'); 

$this->email->initialize(array(
       'protocol' => 'smtp', 
       'smtp_host' => 'smtp.sendgrid.net', 
       'smtp_user' => 'username', 
       'smtp_pass' => 'password', 
       'smtp_port' => 587, 
       'crlf' => "\r\n", 
       'newline' => "\r\n" 
     )); 


     $body = 'some html content'; 
     $this->email->set_mailtype("html"); 
     $this->email->from('[email protected]'); 
     $this->email->to('[email protected]'); 
     $this->email->subject('Please confirm your email'); 
     $this->email->message($body); 
     $this->email->send(); 

這將是巨大的,如果有人能幫助我理解究竟是什麼問題

代碼。

+0

按照谷歌的幫助文章中,我也曾嘗試端口2525 https://cloud.google.com/compute/docs/tutorials/sending-mail/using -sendgrid#sendgrid_smtp_settings –

+0

sendmail協議不會給我一個錯誤,但它也不會傳遞電子郵件。 –

+0

您是否嘗試過使用發送網格的網絡API? – Tom

回答

相關問題