PHP 라이브러리 기타 도서관 이메일 전송을 위한 PHP 클래스
이메일 전송을 위한 PHP 클래스
<?php
class SendM{
  private $Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout,$ms,$ending = "\r\n",$endingc="\n";
  function __construct($Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout){
    $this->Mailhost=$Mailhost;
    $this->Mailuser=$Mailuser;
    $this->Mailpwd=$Mailpwd;
    $this->Mailport=$Mailport;
    $this->Mailtimeout=$Mailtimeout;
    $this->ConnectSmtpServer();
  }
  private function ConnectSmtpServer(){
    if(!is_string($this->Mailhost)){ settype(trim($this->Mailhost),"string"); }
    if(!is_integer($this->Mailport)){ settype(trim($this->Mailport),"integer"); }
    if(!is_integer($this->Mailtimeout)){ settype(trim($this->Mailtimeout),"integer"); }
    $this->ms=@fsockopen($this->Mailhost,$this->Mailport,$this->errorno,$this->errorstr,$this->Mailtimeout);
    if(substr(PHP_OS,0,3) != "WIN"){ stream_set_timeout($this->ms, $this->Mailtimeout, 0);}
    $rcp = $this->get_echo();
    fputs($this->ms,"ehlo bobo".$this->ending);
    $rcp = $this->get_echo();
    if(substr($rcp,0,3)!='250'){ return false; }
    fputs($this->ms,'auth login'.$this->ending);
    $rcp = $this->get_echo();
    if(substr($rcp,0,3)=='334'){ $this->Auth($this->Mailuser,$this->Mailpwd); }else{ return false; } }
  private function Auth($Mailuser,$Mailpwd){
    $this->Mailuseren=base64_encode($Mailuser); $this->Mailpwden=base64_encode($Mailpwd);
    fputs($this->ms,$this->Mailuseren.$this->ending);
    $rcp = $this->get_echo();
    fputs($this->ms,$this->Mailpwden.$this->ending);
    $rcp = $this->get_echo();  }
  private function get_echo(){
    $edata=""; while($estr=@fgets($this->ms,600)){ $edata .= $estr;
      if(substr($estr,3,1) == " ") { break; }  }
    return $edata; }
  public function Send($to,$subject,$connect){
    $host=explode('.',$this->Mailhost);
    $fromaddress=$this->Mailuser.'@'.$host[1].'.'.$host[2];
    fputs($this->ms,'mail from:<'.$fromaddress.'>'.$this->ending);
    $rcp = $this->get_echo();
    fputs($this->ms,'rcpt to:<'.$to.'>'.$this->ending);
    $rcp = $this->get_echo();
    fputs($this->ms,'data'.$this->ending);
    $rcp = $this->get_echo();
    fputs($this->ms,"to:$to".$this->endingc);
    fputs($this->ms,"from:$fromaddress".$this->endingc);
    fputs($this->ms,"subject:$subject".$this->endingc.$this->endingc);
    fputs($this->ms,"$connect".$this->endingc);
    fputs($this->ms,'.'.$this->ending);
    $rcp = $this->get_echo(); if(substr($rcp,0,3)=='250'){header("Location:main_pro.php?act=msg&errors=on&msg=邮件发送成功!已成功提交至对方服务器!"); }else{ header("Location:main_pro.php?act=msg&errors=on&msg=很遗憾,邮件发送失败了!请检查邮件账户配置是否正确!"); }
  }
}
?>

이메일 보내기를 위한 PHP 클래스입니다. 필요한 친구들은 다운로드해서 사용할 수 있습니다.

사용 지침:

$m= new SendM('smtp 서버 주소', '계정', '비밀번호', 포트(int), 시간 초과 재시도 시간(int))

$m->Send( '받는 사람의 이메일','제목','이메일 내용');

사용 예:

$m= new SendM('smtp.yeah.net','testuser','testuserpwd',25,30 );

$m->Send('a@coolmr.com','테스트 이메일','이메일 발송을 위한 테스트 이메일입니다. 지원해 주셔서 감사합니다.');

부인 성명

이 사이트의 모든 리소스는 네티즌이 제공하거나 주요 다운로드 사이트에서 재인쇄되었습니다. 소프트웨어의 무결성을 직접 확인하십시오! 이 사이트의 모든 리소스는 학습 참고용으로만 사용됩니다. 상업적 목적으로 사용하지 마시기 바랍니다. 그렇지 않으면 모든 결과에 대한 책임은 귀하에게 있습니다! 침해가 있는 경우 당사에 연락하여 삭제하시기 바랍니다. 연락처: admin@php.cn

관련 기사

이메일 전송을 위한 PHP 클래스 이메일 전송을 위한 PHP 클래스

25 Jul 2016

이메일 전송을 위한 PHP 클래스

이메일 전송을 위한 PHP 함수 예제 이메일 전송을 위한 PHP 함수 예제

25 Jul 2016

이메일 전송을 위한 PHP 함수 예제

웹페이지 하이퍼링크, 이메일 주소 및 기타 콘텐츠를 추출하기 위한 PHP 구현 코드 웹페이지 하이퍼링크, 이메일 주소 및 기타 콘텐츠를 추출하기 위한 PHP 구현 코드

25 Jul 2016

웹페이지 하이퍼링크, 이메일 주소 및 기타 콘텐츠를 추출하기 위한 PHP 구현 코드

PHP는 HTML 형식 이메일 전송을 위한 전송 클래스를 지원합니다. PHP는 HTML 형식 이메일 전송을 위한 전송 클래스를 지원합니다.

25 Jul 2016

PHP는 HTML 형식 이메일 전송을 위한 전송 클래스를 지원합니다.

PHP의 mail() 기능은 대량 이메일 전송을 위한 신뢰할 수 있는 선택입니까? PHP의 mail() 기능은 대량 이메일 전송을 위한 신뢰할 수 있는 선택입니까?

10 Nov 2024

PHP의 대량 이메일 전달: 장점과 단점 효율적인 대량 이메일 전달을 위해서는 제한 사항과 함정을 고려하는 것이 중요합니다.

PHP 이메일 클래스 보내기 PHP 이메일 클래스 보내기

25 Jul 2016

PHP 이메일 클래스 보내기

See all articles