PHPMailer发送邮件现在php开发者比较常用的一个邮件发送组件了,利用它我们几乎不需要考虑任何问题,只要简单的把代码放网上把邮箱用户名密码与stmp改一下就可以发邮件了.
PHPMailer是别人封装好的一个发送邮件的库,用起来很方便,其支持mail、sendmail和smtp的方式可以到https://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list去下载最新版本的,下面通过gmail smtp发送邮件为例来说明smtp使用方法.
- function sendMail($subject, $body, $to, $ccs = array()) {
- require_once './class.phpmailer.php';
- $mail = new PHPMailer();
- //设定邮件编码,默认ISO-8859-1,也可以直接去源代码中修改
- $mail->CharSet = 'UTF-8';
- // 使用smtp的方式发送
- $mail->IsSMTP();
- //smtp服务器需要认证
- $mail->SMTPAuth = TRUE;
- //安全协议 gmail 是采用ssl的
- $mail->SMTPSecure = "ssl";
- //smtp服务器
- $mail->Host = 'smtp.gmail.com';
- //smtp服务器端口,普通是25
- $mail->Port = 465;
- //smtp 认证用户名和密码
- $mail->Username = 'yourgmailaccount@gmail.com';
- $mail->Password = "yourpassword";
- //发件人地址和名字,名字可以省略
- $mail->SetFrom('yourgmailaccount@gmail.com', 'display name');
- // 邮件标题
- $mail->Subject = $subject;
- // 邮件内容,支持HTML格式
- $mail->MsgHTML($body);
- // 收件人地址
- $mail->AddAddress($to);
- // 抄送人
- foreach ($ccs as $cc) {
- $mail->AddCC($cc);
- }
- if(!$mail->Send()) {
- echo "error info:" . $mail->ErrorInfo;
- }
- }
上面是核心代码,下面我们综合一下实例,按如下示例编写代码即可实现php在线发送邮件.
一:前台表单,代码如下:
- <html>
- <body>
- <h3>phpmailer Unit Test</h3>
- 请你输入<font color="#FF6666">收信</font>的邮箱地址:
- <form name="phpmailer" action="send.php" method="post">
- <input type="hidden" name="submitted" value="1"/>
- 邮箱地址: <input type="text" size="50" name="address" />
- <br/>
- <input type="submit" value="发送"/>
- </form>
- </body>
- </html>
二:后台PHP程序,代码如下:
- <?php
- require("class.phpmailer.php"); //下载的文件必须放在该文件所在目录
- $mail = new PHPMailer(); //建立邮件发送类
- $address = $_POST['address'];
- $mail->IsSMTP(); // 使用SMTP方式发送
- $mail->Host = "mail.xxxxx.com"; // 您的企业邮局域名
- $mail->SMTPAuth = true; // 启用SMTP验证功能
- $mail->Username = "user@xxxx.com"; // 邮局用户名(请填写完整的email地址)
- $mail->Password = "******"; // 邮局密码
- $mail->From = "user@xxxx.com"; //邮件发送者email地址
- $mail->FromName = "您的名称";
- $mail->AddAddress("$address", "");//收件人地址,可以替换成任何想要接收邮件的email信箱,格式是AddAddress("收件人email","收件人姓名")
- //$mail->AddReplyTo("", "");
- //$mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件
- //$mail->IsHTML(true); // set email format to HTML //是否使用HTML格式
- $mail->Subject = "PHPMailer测试邮件"; //邮件标题
- $mail->Body = "Hello,这是测试邮件"; //邮件内容
- $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加信息,可以省略
- if(!$mail->Send())
- {
- echo "邮件发送失败. <p>";
- echo "错误原因: " . $mail->ErrorInfo;
- exit;
- }
- echo "邮件发送成功";
- ?>
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » 使用PHPMailer发送邮件实例代码总结
波比源码 » 使用PHPMailer发送邮件实例代码总结
levaquin for sale online cost levaquin 500mg
buy dutasteride without prescription celecoxib 100mg over the counter buy zofran pills
generic aldactone 25mg order aldactone 25mg generic order diflucan 200mg for sale
ampicillin uk erythromycin 500mg for sale erythromycin 250mg tablet
fildena online buy robaxin 500mg online cheap methocarbamol cost
buy suhagra for sale estrace 1mg price estradiol uk
lamotrigine 50mg pill brand vermox retin cream generic
buy tadalafil pill purchase diclofenac generic order voltaren generic
accutane 40mg uk brand zithromax zithromax sale
order indomethacin 75mg generic order amoxicillin 250mg pills amoxicillin over the counter
order tadalafil 5mg for sale online drugstore viagra pill
anastrozole 1mg ca arimidex 1mg pills viagra for women
prednisone 40mg oral purchase sildenafil generic sildenafil mail order us
cialis 10mg generika rezeptfrei kaufen viagra 100mg kaufen ohne rezept sildenafil 200mg bestellen
order modafinil online provigil cheap diamox pill
buy clonidine 0.1 mg generic generic clonidine 0.1 mg cheap tiotropium bromide
order buspirone generic cheap buspirone 5mg buy oxybutynin 5mg without prescription
hytrin 5mg us generic pioglitazone order generic azulfidine 500mg
alendronate 35mg without prescription alendronate pill famotidine 20mg pill
buy generic benicar verapamil 240mg generic diamox 250 mg sale
purchase prograf for sale ropinirole us buy generic ursodiol 150mg
order molnupiravir 200mg generic naproxen 500mg pill purchase prevacid pills
tadalafil 5mg us Cialis for sale usa pharmacy viagra
order naltrexone online cheap aripiprazole 20mg pill order abilify 30mg
medroxyprogesterone tablet biltricide 600mg drug buy generic periactin 4 mg
luvox over the counter buy generic duloxetine glipizide brand
cost isotretinoin order amoxil 1000mg sale deltasone 20mg us
zithromax order online prednisolone 20mg uk buy neurontin
lasix 100mg pills purchase hydroxychloroquine for sale hydroxychloroquine 200mg brand
norvasc online order tadalafil 20mg online cialis 10mg price
cialis viagra sales order lisinopril 5mg buy lisinopril online cheap
linezolid online buy online slots real money spins real money online
purchase lopressor pill buy levitra 10mg online cheap order vardenafil 20mg
assignment sites play casino slots best online casinos real money
order vardenafil 10mg generic pregabalin 75mg for sale buy medrol 4mg
write papers for me do my research paper purchase viagra generic
price of cialis sildenafil 150mg for sale viagra 150mg for sale
triamcinolone 4mg pill aristocort 4mg uk buy desloratadine 5mg online
buy tadalafil 10mg pill viagra 100mg cheap viagra 50mg generic
allopurinol 100mg brand buy ezetimibe sale purchase zetia
methotrexate 10mg drug order reglan 10mg online reglan 10mg generic
order losartan 50mg online cheap buy esomeprazole 20mg pill order generic topiramate
ranitidine cost buy meloxicam 7.5mg generic order generic celecoxib
online slots real money sports gambling best online blackjack real money
order metronidazole 200mg without prescription buy trimethoprim trimethoprim oral
order diflucan generic sildenafil 100mg sale purchase sildenafil
keflex 500mg drug cephalexin 125mg uk erythromycin 250mg cheap
cialis viagra sales cost sildenafil cialis 5mg uk
purchase cefuroxime pills buy careprost online cheap methocarbamol drug
oral sildenafil 50mg sildenafil pills 200mg generic for cialis
real casino order cialis without prescription order cialis sale
online blackjack for money blackjack free online provigil 200mg drug
buy fildena fildena uk oral budesonide
order tretinoin cream generic order tadalis 20mg online cheap buy avanafil 100mg sale
buy tadacip 20mg pill cost diclofenac 100mg buy indocin generic
terbinafine 250mg cost buy trimox 500mg without prescription trimox 500mg over the counter
purchase naproxen purchase omnicef without prescription buy prevacid 15mg for sale
singulair sale viagra 50mg brand order viagra online
cialis pills 40mg Discount cialis casino online usa
buy cialis 20mg pill buy erection pills cost of cialis
play roulette for free online gambling slots games poker online for real money
stromectol for lice order stromectol online dapsone 100 mg brand
online gambling casino moons online casino free spins no deposit casino
doxycycline 200mg generic doxycycline 100mg oral buy cleocin 300mg pill
buy asacol generic mesalamine usa irbesartan 150mg cheap
purchase olmesartan without prescription calan 240mg brand depakote 250mg cheap
buy nortriptyline 25 mg for sale nortriptyline without prescription purchase paxil pills
oral tadacip 10mg order clopidogrel 75mg without prescription order trimox 250mg generic
cost nexium order biaxin 500mg sale cheap furosemide 100mg
Thank you for great information. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
minocycline us hytrin 1mg cheap buy terazosin 1mg online cheap
cialis black levitra free cheap ed drugs
isotretinoin 20mg price order ampicillin 500mg online cheap acillin cheap
ivermectin 9mg buy prednisone 40mg without prescription deltasone oral
zofran 8mg over the counter amoxil order online bactrim 480mg price
buy isotretinoin 20mg pills buy azithromycin 250mg generic order azithromycin 500mg generic
prednisolone 10mg generic buy gabapentin 600mg online cheap brand lasix 40mg
doxycycline 200mg usa buy doxycycline buy zovirax 800mg without prescription
Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
Порой молодой психоаналитик старается впустить пациента в свою жизнь, поделиться своим опытом, тем самым надеясь на ответную искренность со стороны пациента.
Такой метод не позволяет придерживаться психоаналитической почвы, и
сводит все к обыкновенному внушению.
Врачу следует избегать такой близости с
больным. Его долг – отражать именно то, что говорит пациент.
форма
order uroxatral pills trazodone 100mg usa diltiazem online order
buy promethazine for sale cialis in usa cialis on line
buy cheap generic coumadin warfarin 5mg uk zyloprim sale
lexapro 20mg generic order lexapro generic revia 50mg tablet
cialis usa natural ed pills buy ed medications online
ivermectin usa price deltasone 40mg drug accutane oral
buy provigil cheap provigil 200mg drug order prednisone 5mg sale
buy clomid for sale cheap clomid plaquenil 200mg usa
poip-nsk.ru
brand levothroid buy serophene online buy generic vardenafil 10mg
lyrica price buy dapoxetine 90mg buy dapoxetine no prescription
methotrexate 10mg for sale reglan tablet oral reglan 10mg
order orlistat orlistat 60mg drug oral zyloprim
в плену у призраков фильм
brand sumycin 500mg baclofen online buy baclofen 10mg generic
order toradol 10mg inderal 20mg over the counter propranolol brand
purchase clopidogrel sale fluvoxamine medication nizoral pills
tamsulosin uk cheap zofran 4mg spironolactone pills
betnovate 20 gm for sale order betnovate 20gm cream sporanox pill
prometrium sale order zyprexa without prescription order olanzapine 10mg pills
order bystolic 20mg online cheap purchase diovan generic clozapine price
nateglinide tablet nateglinide pills candesartan online buy
zocor cost order sildenafil 50mg online cheap buy generic viagra 100mg
brand tegretol 200mg tegretol sale purchase lincocin pill
how to get minocin without a prescription brand actos buy pioglitazone 15mg online
order leflunomide 10mg for sale buy leflunomide 20mg online cheap azulfidine 500mg brand
order azipro 500mg online oral omnacortil 20mg neurontin 800mg over the counter
cialis 20mg oral cialis overnight generic tadalafil 40mg
ivermectin 400 mg pills for ed order prednisone 40mg pills
buy vardenafil pills zanaflex pill buy plaquenil 400mg sale
ramipril 5mg cheap buy arcoxia 60mg pill etoricoxib 60mg tablet
mesalamine 800mg over the counter order azelastine sprayer buy irbesartan 150mg without prescription
order benicar 20mg pills order benicar 10mg pills divalproex 250mg tablet
order carvedilol order cenforce 100mg sale buy chloroquine online cheap