dongpiao0731 2016-09-11 06:07
浏览 41

使用phpmailer将电子邮件发送到固定地址,但来自不同的来源

I have a page in my website (contacts.html) that as a form to send emails to a specific fount (email that a create to receive those emails from different founts).I'm using Postmark as host.

this is the code to send email (using phpmailer, and already have the html form):

if(isset($_POST['send'])){

$name = $_POST['sendName'];
$email = $_POST['sendEmail'];
$subject = $_POST['sendSubject'];
$message = $_POST['sendMessage'];
$password = $_POST['sendPass'];

require_once('phpmailer/class.phpmailer.php');
require_once('phpmailer/class.smtp.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.postmarkapp.com";
$mail->Port = 2525; // or 587 //or 25
$mail->IsHTML(true);
$mail->Username = $email;
$mail->Password = $password;
$mail->From = $email;
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddAddress("teste2x2016@gmail.com","jon");

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

}

so the problem is I pass the email and the password of that same email (when someone want to send email to the one that I create), and the code fail like this:

SMTP -> ERROR: Password not accepted from server: 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6 SMTP -> ERROR: RCPT not accepted from server: 454 4.7.1 : Relay access denied SMTP Error: The following recipients failed: teste2x2016@gmail.com Mailer Error: SMTP Error: The following recipients failed: teste2x2016@gmail.com SMTP server error: 4.7.1 : Relay access denied

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c