PHP는 SMTP를 사용하여 이메일을 보냅니다(PEAR)
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-07-25 09:09:15
PHPer 多数使用 mail 函数来发送邮件,但我们可以使用其他的 SMTP 服务器来发送,这里推荐使用
PEAR’s mail package 来发送邮件。
- $subject = "This mail is sent from SMTP.";
- $mail_body = "This is the body of the mail which is sent using SMTP.";
- $from = "From: From Name ";
- $to = "To: To Name ";
- $receiver = "toaddress@xpertdeveloper.com";
-
- // Setting up the headers
- $headers["From"] = $from;
- $headers["To"] = $to;
- $headers["Subject"] = $subject;
- $headers["Reply-To"] = "reply@address.com";
- $headers["Content-Type"] = "text/plain; charset=ISO-2022-JP";
- $headers["Return-path"] = "returnpath@address.com";
-
- // Setting up the SMTP setting
- $smtp_info["host"] = "smtp.server.com";
- $smtp_info["port"] = "25";
- $smtp_info["auth"] = true;
- $smtp_info["username"] = "smtp_user";
- $smtp_info["password"] = "smtp_password";
-
- // Creating the PEAR mail object :
- $mail_obj =& Mail::factory("smtp", $smtp_info);
-
- // Sending the mail now
- $mail_sent = $mail_obj->send($receiver, $headers, $mail_body);
-
- // If any error the see for that here:
- if (PEAR::isError($mail_sent)) { print($mail_sent->getMessage());}
复制代码
|
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
저자별 최신 기사
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
최신 이슈
-
2025-03-26 19:56:00
-
2025-03-26 19:55:08
-
2025-03-26 19:52:08
-
2025-03-26 19:51:12
-
2025-03-26 19:50:14