Php邮件程序

编程入门 行业动态 更新时间:2024-10-25 13:19:02
本文介绍了Php邮件程序 - 无法发送邮件。邮件程序错误:无效地址:(cc):的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用PHPMailer类并对某些邮件地址使用$ Variables。 问题是如果$ Variable为空,PHP Mailer会回复: -

I am using PHPMailer class and using $Variables for some of the mail addresses. The problem is that if the $Variable is empty, PHP Mailer responds with :-

Message could not be sent. Mailer Error: Invalid address: (cc):

代码的一部分如下:: -

A portion of the code is as follows::-

$mail = new PHPMailer(true); // Passing `true` enables exceptions try { //Server settings //$mail->SMTPDebug = 2; // Enable verbose debug output $mail - > isSMTP(); // Set mailer to use SMTP $mail - > Host = 'mail.smtp2go'; // Specify main and backup SMTP servers $mail - > SMTPAuth = true; // Enable SMTP authentication $mail - > Username = 'xxx'; // SMTP username $mail - > Password = 'xxx'; // SMTP password $mail - > SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail - > Port = 2525; // TCP port to connect to //Recipients $mail - > AllowEmpty = true; $mail - > setFrom('adrian@ic-express.co.za', 'Adrian Boshoff'); //$mail->addAddress($mrow['email']); //This is an example of creating a variable from an array field $mail - > addAddress($email); //This is an example of creating a variable from an array field $mail - > addReplyTo('adrian@ic-express.co.za'); $mail - > addCC($addemail); $mail - > AllowEmpty = true; //$mail->addBCC('adrian@ic-express.co.za'); //Attachments $mail - > addAttachment('eco.pdf'); // Add attachments //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name $mail - > isHTML(true); // Set email format to HTML $mail - > Subject = $subject; $mail - > Body = << < END < !doctype html > < html xmlns = "www.w3/1999/xhtml" xmlns: v = "urn:schemas-microsoft-com:vml" xmlns: o = "urn:schemas-microsoft-com:office:office" > < head > <!-- NAME: SELL PRODUCTS -->

我尝试过的方法: 我尝试添加

What I have tried: I tried adding

$mail->AllowEmpty = true;

哪个没有帮助。

Which has not helped.

推荐答案

某些邮件地址的变量。 问题是如果 Variables for some of the mail addresses. The problem is that if the

变量为空,PHP Mailer会响应: - Variable is empty, PHP Mailer responds with :- Message could not be sent. Mailer Error: Invalid address: (cc):

代码的一部分如下:: -

A portion of the code is as follows::-

mail = new PHPMailer(true); //传递`true`启用例外 try { //服务器设置 // mail = new PHPMailer(true); // Passing `true` enables exceptions try { //Server settings //

更多推荐

Php邮件程序

本文发布于:2023-08-07 10:26:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1318615.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:邮件   程序   Php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!