php发送邮件(方法一)_PHP教程

WBOY
Libérer: 2016-07-13 17:51:58
original
953 Les gens l'ont consulté

[html] 
1. 实例:    
[html] 
1.        $content       ="ceshi"; 
2.        $technicalemail="www.2cto.com"; 
3. $headers       = "From: =?utf-8?B?".base64_encode('chenglong')."?= \r\n"; 
4.  
5. $content       = strip_tags($content); 
6. $a             = @mail($technicalemail,'=?utf-8?B?'.base64_encode('出错提交').'?=',$content,$headers); 
7.        if($a) 
8.  { 
9.  echo '邮件发送成功!'; 
10.  } 
 通过mail()函数发送:
   1,需要配置php.ini邮件信息
        打开php.ini配置文件,配置红色的位置
             ; For Win32 only.
             SMTP = localhost  ---如果本机装了sendmail,这个表示使用本地邮件服务器,也可以是ip地址,还有服务器域名
             smtp_port = 25    ---端口号
             ; For Win32 only.
             ;sendmail_from = www.2cto.com  ---可写可不写   把这里的分号去掉
             ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
             ;sendmail_path =    ----邮件服务器的路径
  2.mail()函数
        mail()函数允许从脚本直接发送电子邮件
        mail()函数返回的是boolean值,成功返回true,失败返回flase
    
        mail(to,subject,message,headers,paeameters);
       
         to --必需,规定邮件的接收者
         subject --必需,规定邮件的主题,该参数不能包含任何换行字符
         message --必需,规定要发送的消息
         headers --可选,规定额外的报头,比如from,Cc以及Bcc 可以参考一些资料
         parameters --可选,规定sendmail程序的额外参数
3. php.ini 中  将extension=php_imap.dll前面的“;”去掉
          

 作者:Vericlongmore

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478152.htmlTechArticle[html] 1.span style=font-size:18px;实例:/span [html] 1. $content =ceshi; 2. $technicalemail=www.2cto.com; 3.$headers = From: =?utf-8?B?.base64_encode(chenglong).?= $technicalemai...
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!