簡體   English   中英

如何在不訪問php.ini的情況下啟用擴展名(openssl ...)?

[英]how to enable extension (openssl,…) without access to php.ini?

我正在使用codeigniter發送郵件,但是共享主機出現問題,因為我無法訪問php.ini,因此出現以下錯誤:

A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465
(Connection timed out)
Message: fwrite() expects parameter 1 to be resource, boolean given
Message: fgets() expects parameter 1 to be resource, boolean given

我也使用.htaccess使用此內容:

php_extension openssl.so

但是我得到了這個錯誤:

內部服務器錯誤

服務器遇到內部錯誤或配置錯誤,無法完成您的請求。 服務器錯誤日志中可能會提供有關此錯誤的更多信息。 此外,嘗試使用ErrorDocument處理請求時遇到500內部服務器錯誤錯誤。

我也讀過很多關於這個問題的話題,但是沒有一個能解決我的問題。 現在,我不知道該怎么辦!

更新:我在主機中發現了一些東西,我更加困惑了! 我這樣寫:

if (extension_loaded('openssl')) 
{
    echo "enabled";     
}
die();

那么為什么我會收到這些錯誤:

A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465
(Connection timed out)
Message: fwrite() expects parameter 1 to be resource, boolean given
Message: fgets() expects parameter 1 to be resource, boolean given

php具有dl()以在運行時啟用擴展,請參見http://php.net/manual/zh/function.dl.php

dl —在運行時加載PHP擴展

這樣嘗試

 function load_lib($n, $f = null)
 {
  return extension_loaded($n) or dl(((PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '') . ($f ? $f : $n) . '.' . PHP_SHLIB_SUFFIX);
 }

load_lib('openssl');

OpenSSL必須使用PHP進行編譯 ,因此您可能不會在共享托管中使用該選項。

嘗試切換到SendGrid-它們具有免費使用層 ,該允許您每天發送400封電子郵件以及適用於PHP的大量示例代碼

我通過使用托管主機的郵件服務器而不是Gmail解決了我的問題。 無論如何,我找不到通過gmail發送郵件!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM