在阿里云ACE上使用Cimy Swift SMTP插件发送邮件。

Wordpress1年前 (2023)发布 SUYEONE
960 0 0

WordPress can run smoothly on Alibaba Cloud Elastic Compute Service (ECS) without any modifications, making it an attractive option for many WordPress users due to its free, fast, and stable performance. However, one issue that may arise when migrating from a VPS to ACE is the inability to send emAIls. On the VPS, using the Cimy Swift SMTP plugin with SMTP for email delivery worked well, but on Alibaba Cloud, you might encounter an error message stating “SMTP connect() failed,” indicating a Failure to connect to the mail server.

After submitting a support ticket to Alibaba Cloud, you’ll learn that while ACE does support sending emails, it requires a different approach. The recommended solution is to replace the `stream_socket_client` function with `fsockopen`. Both functions serve similar purposes, but `fsockopen` is more suitable for ACE’s environment.

To modify the Cimy Swift SMTP plugin for compatibility with ACE, locate the `stream_socket_client` function in `Cimy-Swift-SMTP/Swift/lib/Classes/Swift/Transport/stream_buffer.php` at line 263:

“`php
$this->_stream = @stream_socket_client($host . ‘:’ . $this->_params[‘port’], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
“`

Replace this with:

“`php
$this->_stream = @fsockopen($host, $this->_params[‘port’], $errno, $errstr, $timeout);
“`

Commit the changes to your version control system, redeploy the application, and test the email functionality through the Cimy Swift SMTP plugin settings. You should now be able to send emails promptly, including comment replies and password resets.

For your convenience, I’ve prepared a modified plugin package available for download. [Download the modified Cimy Swift SMTP plugin here](#download_link).

If you’re looking to improve performance further, consider using an Alibaba Cloud ECS server, especially if your Website has a daily page view (PV) below 100. If your traffic is higher, an ECS server can better handle the load. Migrating to an ECS server won’t require moving Data from Object Storage Service (OSS) or Relational Database Service (RDS), as they can be directly configured.

Click the following link to purchase an Alibaba Cloud ECS server with a 15% discount: [Buy Alibaba Cloud ECS Server](#buy_link).

**Update as of 2015/05/19**: It appears that WangWan’s virtual hosting service also experiences similar issues, possibly due to the same system architecture. The aforementioned method has been tested and works on WangWan’s Platform as well.

© 版权声明

相关文章

暂无评论

暂无评论...
☺一键登录开启个人书签等功能!