3 Modules giúp Debug Emails trong Drupal 7

3 Modules giúp Debug Emails trong Drupal 7

Hướng dẫn sử dụng Redux để quản lý hiệu quả trong ứng dụng React

Average: 7.7 (3 votes)

Cài đặt Webpack để viết Reactjs bằng ES6 và những thuận lợi của ES6

Average: 9.5 (2 votes)

3 Modules giúp Debug Emails trong Drupal 7

Debugging email issues in Drupal can be really painful. Problems can exist in multiple areas; like Drupal itself or your mail server. So when an email issue arises you first need to check and see if Drupal is generating emails and then make sure your mail server is sending the emails. Luckily in Drupal there are a few modules that can lessen the pain of debugging emails.

In this article, I'll introduce you to a few modules that can help you debug email issues. More importantly these same modules can help you develop and test custom email functionality in Drupal.

Intercept Emails Using Devel Module

One useful way of debugging and testing emails is to use the custom mail class that ships with the Devel module. The mail class intercepts all outgoing emails and stores them in Drupal's temporary directory. The path of the temporary directory can be configured from the Configure -> File system page.

It’s important to note that none of the emails will actually be sent, they’ll instead be stored in the temporary directory.

Fig 1.0

Setting up Devel to log outgoing emails is pretty simple.

  1. First, make sure you download and install the Devel module.
  2. Add the code below into the settings.php.
$conf['mail_system'] = array(
'default-system' => 'DevelMailLog',

All we’re doing is telling Drupal to use the DevelMailLogclass as the default mail system.

3. Flush the site cache.

Once you have fired off a few emails go to the temporary directory, and you should see a folder called devel-mailsfull of logged emails.

Fig 1.1

Log Emails Using Mail Logger Module

The Mail Logger simply logs all outgoing emails into a database table. You can view the logged emails by going to the Reports -> Outgoing Mail log entries page. Just remember that emails will still be sent, this module just logs a copy of the emails.

Fig 1.2

Re-route All Emails Using Reroute Email Module

The Reroute Email module intercepts all outgoing emails and sends them to a configurable email address. This module is great for testing email notifications on a development or staging site. Any email that is generated by Drupal will be sent to predefined email addresses instead of end users.

Configuring the module is very easy.

1. Download and install the Reroute Email module.

2. Go to Configuration-> Reroute Email (admin/config/development/reroute_email).

3. Check the Enable rerouting checkbox and enter in an email address into the Email addresses text field.

Fig 1.3

Bonus: Debug and Modify Emails Using hook_mail_alter()

If you need to modify or debug an email as it’s being generated within Drupal, then look at implementing the hook_mail_alter() hook.

Install the Devel module and add the following code into a custom module. Replace EXAMPLEwith the module name.

* Implements hook_mail_alter().
function EXAMPLE_mail_alter(&$message) {

After you have sent off an email you should see the $messageprinted in the message area.

3 Modules giúp Debug Emails trong Drupal 7


Debugging an email issue is a simple two step process. First, make sure Drupal is generating the emails. Double check your code if you’re sending emails programmatically. Second, make sure the emails are being sent. This may require some digging through mail logs on the server.

Bạn thấy bài viết này như thế nào?: 
No votes yet




Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

Hướng dẫn xóa Drupal Field Saved vào Features
Hướng dẫn xóa Drupal Field Saved vào Features

There comes a time in every Drupal developer's day when they realize they really don't need a field on some content type or other entity. Maybe it was a field holding temporary data while you did a migration or maybe a feature

Google adsence
Những điều cần tránh khi kiếm tiền với Google Adsense

Khi trang web bạn đã có traffic, có thứ hạng cao trên bộ máy tìm kiếm thì bạn có thể kiếm tiền từ nhiều nguồn khác nhau không chỉ riêng gì Google Adsense. Nhưng ai cũng biết một điều, Google Adsense là công ty trả tiền tốt nhất tại thời điểm hiện tại. Tuy nhiên không phải website với nội dung nào cũng được Google Adsense chấp nhận. Để tránh tình trạng không đăng ký được Google Adsense hoặc bị disable ads, ban account, bạn phải theo đúng quy định của họ.

Tìn hiểu Nginx - server cân bằng tải, Unicorn - server HTTP cho Ruby
Tìn hiểu Nginx - server cân bằng tải, Unicorn - server HTTP cho Ruby

Nginx (pronounced “Engine-X”) : Là sản phẩm mã nguồn mở cho web server . Là một reverse proxy cho các giao thức HTTP, SMTP, POP3 and IMAP