How IT

언제든지 물어보세요.

컨텐츠로 건너뛰기
  • 홈
  • Unix
  • Apple
  • Java
  • Android
  • C#
  • C++

WordPress의 wp_mail 기능을 사용하여 HTML 형식의 전자 메일을 보내는 방법이 있습니까? 함수를 사용하여 이메일을 시작했습니다. $email_to =

이것을 달성하는 데 도움이되는 action_hook 또는 이와 유사한 것이 있습니까?

PHP 문자열 변수에 마크 업을 추가하려고 시도했고 wp_mail 함수를 사용하여 이메일을 시작했습니다.

$email_to = 'someaddress@gmail.com';
$email_subject = 'Email subject';
$email_body = "<html><body><h1>Hello World!</h1></body></html>";
$send_mail = wp_mail($email_to, $email_subject, $email_body);

그러나 그것은 평문으로 나타 났습니까?

어떤 아이디어?



답변

에서 wp_mail 사본 페이지 :

기본 컨텐츠 유형은 ‘text / plain’이며 HTML 사용을 허용하지 않습니다. 그러나 ‘wp_mail_content_type’필터를 사용하여 이메일의 컨텐츠 유형을 설정할 수 있습니다.

// In theme's functions.php or plug-in code:

function wpse27856_set_content_type(){
    return "text/html";
}
add_filter( 'wp_mail_content_type','wpse27856_set_content_type' );


답변

대안으로 $ headers 매개 변수에 Content-Type HTTP 헤더를 지정할 수 있습니다.

$to = 'sendto@example.com';
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');

wp_mail( $to, $subject, $body, $headers );


답변

wp_mail 함수를 사용한 후에 컨텐츠 유형 필터를 제거하는 것을 잊지 마십시오. 허용되는 답변의 이름을 지정한 후에 wp_mail이 실행 된 후에이 작업을 수행해야합니다.

remove_filter( 'wp_mail_content_type','wpse27856_set_content_type' );

이 티켓을 확인하십시오-컨텐츠 유형을 재설정하여 충돌을 피하십시오-http: //core.trac.wordpress.org/ticket/23578


답변

HTML로 모든 이메일을 보내려면 http://wordpress.org/plugins/email-templates 와 같은 플러그인을 사용할 수도 있습니다


답변


이 글은 wordpress 카테고리에 분류되었고 hooks, html, html-email, wp-mail 태그가 있으며 소장 마님에 의해 2022-02-06에 작성되었습니다.

글 네비게이션

← 파일을 열고 닫은 후 Finder에 초점을 다시 맞출 수 있습니까 (예 : 편집기에서)? 파일의 TextEdit)에서 파일을 닫을 때 응용 프로그램은 다른 사용자의 환경 변수 가져 오기 질문을 명확하게 설명 하려면 →

태그

  • android
  • apt
  • bash
  • boot
  • c#
  • c++
  • code-golf
  • command-line
  • debian
  • firefox
  • git
  • google-chrome
  • hard-drive
  • html
  • java
  • keyboard
  • linux
  • mac
  • macos
  • math
  • memory
  • microsoft-excel
  • mysql
  • networking
  • performance
  • permissions
  • python
  • r
  • regression
  • security
  • shell
  • sql-server
  • ssh
  • string
  • terminal
  • ubuntu
  • unity
  • usb
  • vim
  • virtualbox
  • windows
  • windows-7
  • windows-8
  • windows-10
  • windows-xp

최신 글

  • Windows에서 파티션 크기를 조정 한 후 APFS 파티션이 손실 됨 00 80
  • App Store에서 El Capitan을 강제로 다시 다운로드 하시겠습니까? 업데이트 된 플래시 드라이브 설치 프로그램을 빌드하기
  • 기존 시스템에 부팅 드라이브로 SSD 추가 백업에 큰 관심이 없습니다. 내가 걱정하는 것은이
  • geoJSON featureCollection에 properties 요소를 갖는 것이 유효합니까?
  • 추세를 식별하기 위해 신호 처리 원리를 신중하게 사용 매우 시끄러운 장기 데이터에서 추세를

카테고리

  • Android
  • Apple
  • C#
  • C++
  • cooking
  • cs
  • cstheory
  • diy
  • drupal
  • electronics
  • emacs
  • Gis
  • Git
  • Html
  • Java
  • Javascript
  • magento
  • photo
  • Python
  • raspberrypi
  • scicomp
  • Server
  • Software
  • Sql
  • stats
  • Superuser
  • ubuntu
  • Unix
  • vi
  • webapps
  • webmasters
  • wordpress
  • 게임개발
  • 코딩
Proudly powered by WordPress
Go to mobile version
Close