tailieunhanh - Drupal 7 Module Development phần 5

Bất kỳ hook_mail () thực hiện có thể định nghĩa một số e-mail, xác định duy nhất một phím văn bản. (Người sử dụng mô-đun Drupal thực hiện mười tám (!) Cho những thứ như xác nhận tài khoản và mật khẩu đã quên). Chúng tôi xác định cụ thể thư | Chapter 5 The second argument warn is a key which is passed to hook_mail . Any hook_mail implementation can define several e-mails uniquely identified by a text key. Drupal s user module implements eighteen for things like account confirmation and forgotten passwords . We specify which specific mail we want to send with this parameter. The third argument contains the recipient s address. We pull this out of the user object for the user whose profile we visited as passed by the confirmation form above. The fourth argument specifies what language the mail should be sent in. This is important because individual users can specify a language preference that is different from the site s default language. We should honor this choice if possible when sending our e-mail to this user. The user_preferred_ language function makes this task easy by taking a user object and returning the user s language choice. The fifth argument is an associative array of parameters to be passed to hook_mail . Any custom information needed to build the e-mail should be put here. In our case any custom information we need to build the e-mail is already in the data submitted from the confirmation form so we will just use form_state values here. The sixth argument contains the e-mail address from whom this mail should be sent. When you first installed Drupal you had to specify an administrative e-mail address. This address is already being used as the source for other system e-mails like account verification so it makes sense to use it as our sender e-mail as well. The e-mail is stored as a persistent variable with the key site_mail so we can easily grab it using variable_get as discussed earlier in the chapter. Finally the last variable indicates whether or not the mail should actually be sent. It will come as no surprise to learn that a mail message in Drupal is built in a specially structured associative array. At the end of the mail building process this array is typically passed to the .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.