使用php发送电子邮件 [英] Email sending using php

查看:169
本文介绍了使用php发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨,,



如何使用php发送邮件..

请帮我清除以下错误。谢谢你提前,



我的代码是:



 $ config = Array 

'protocol'=>'smtp',
'smtp_host'=>'smtp.gmail.com',
'smtp_port'=> 465,
'smtp_user'=>'*******',
'smtp_pass'=>'******',
'mailtype'=>'html',
'charset'=>'iso-8859-1',
'starttls'=> true,
);

$ this-> load-> library('email',$ config);

$ this-> email-> set_newline(\\\\ n);

$ this-> email-> from('****','Ramkumar');
$ this-> email-> to(*****);
$ this-> email-> subject(测试邮件);
$ this-> email-> message(使用Php测试邮件);
$ this-> email-> send();
echo $ this-> email-> print_debugger();死;







尝试运行后的错误:





 1)遇到PHP错误

严重性:警告

消息:fsockopen( ):无法连接到localhost:25(尝试以其访问权限禁止的方式访问套接字。)

文件名:libraries / Email.php

行号:1689







 2)
PHP遇到错误

严重性:警告

消息:fwrite()期望参数1为资源,布尔值为

文件名:libraries / Email。 php

行号:1846

解决方案

config = Array

' protocol'=>'smtp',
'smtp_host'=>'smtp.gmail.com',
'smtp_port'=> 465,
'smtp_user'=>' *******',
'smtp_pass'=>'******',
'mailtype'=>'html',
'charset'=> 'iso-8859-1',
'starttls'=> true,
);


this-> load-> library('email',


config);

Hi,,

How to send mail using php..
Please help me to clear the following errors..Thanks in advance,

My code is:

$config = Array
		(
          'protocol' => 'smtp',
          'smtp_host' => 'smtp.gmail.com',
          'smtp_port' => 465,
          'smtp_user' => '*******',
          'smtp_pass' => '******',
          'mailtype'  => 'html', 
          'charset'   => 'iso-8859-1',
		  'starttls'  => true,
        );
			
      $this->load->library('email', $config);
      
	  $this->email->set_newline("\r\n");
	  
	  $this->email->from('****','Ramkumar');
      $this->email->to("*****");
      $this->email->subject("Test mail");
      $this->email->message("Test Mail using Php");
      $this->email->send();  
	  echo $this->email->print_debugger(); die;




My Errors after trying to run:


1) A PHP Error was encountered

Severity: Warning

Message: fsockopen(): unable to connect to localhost:25 (An attempt was made to access a socket in a way forbidden by its access permissions. )

Filename: libraries/Email.php

Line Number: 1689




2) 
A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1846

解决方案

config = Array ( 'protocol' => 'smtp', 'smtp_host' => 'smtp.gmail.com', 'smtp_port' => 465, 'smtp_user' => '*******', 'smtp_pass' => '******', 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'starttls' => true, );


this->load->library('email',


config);


这篇关于使用php发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆