Godaddy phpmailer smpt配置 [英] Godaddy phpmailer smpt configuration
问题描述
我们在godaddy服务器上有一个站点.我们有联系表.当用户填写表格时,首先我们应该将邮件发送到我们的info @ oursite,然后再将邮件从我们的info @ oursite发送到用户的邮件.我在下面试过的代码:
$name = $_POST['name'];
$email = $_POST['email'];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->port = 25;
$mail->Host = 'localhost';
$mail->Username = 'username@example.com';
$mail->Password = 'password';
$mail->addAddress($email, $name);
$mail->subject = 'Subject';
$mail->MsgHTML('mail içeriği');
if ($mail->Send()){
此输出如下:
似乎邮件已传递,但是它从未传递邮件. 我尝试了很多事情;
$ mail-> SMTPAuth = true;
端口25、80、3535、465(带有ssl), tls,ssl身份验证
我该怎么办?我应该尝试什么,有什么想法?
首先,您使用的是旧版本的PHPMailer; 获取最新信息.
我不知道您的代码在哪里,但是您遇到了一些重要属性错误的情况-我建议您将代码基于PHPMailer提供的示例.特别地,subject
应该是Subject
,port
应该是Port
.发送到localhost时,不需要用户名或密码,因此无需设置它们.同样,Port
默认为25,因此您无需设置它.
您没有指定发件人地址,并且您传递给addAddress
的任何地址似乎都是无效的,因此您正在向任何人发送消息给任何人-毫不奇怪,它没有任何作用! /p>
您的邮件正文似乎是土耳其语(?),在默认的ISO-8859-1字符集中无法使用,因此建议您通过设置$mail->CharSet = 'UTF-8';
切换到UTF-8.
在调用addAddress时检查返回值,以确保提交的值在尝试发送之前是有效的.
这些问题已解决:
$name = $_POST['name'];
$email = $_POST['email'];
$mail = new PHPMailer;
if (!$mail->addAddress($email, $name)) {
die('Invalid email address');
}
$mail->isSMTP();
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug = 2;
$mail->Host = 'localhost';
$mail->Subject = 'Subject';
$mail->msgHTML('mail içeriği');
$mail->setFrom('me@example.com', 'My Name');
if ($mail->send()) {
echo 'Sent';
} else {
echo 'Error: '.$mail->Errorinfo;
}
We have a site on godaddy server. We have a contact form. When user filled form, first we should send mail to our info@oursite, after we should send mail to user's mail from our info@oursite. My tried code below:
$name = $_POST['name'];
$email = $_POST['email'];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->port = 25;
$mail->Host = 'localhost';
$mail->Username = 'username@example.com';
$mail->Password = 'password';
$mail->addAddress($email, $name);
$mail->subject = 'Subject';
$mail->MsgHTML('mail içeriği');
if ($mail->Send()){
this outputs below:
it seems mail delivered, but it never delivered the message. I tried many things;
$mail->SMTPAuth = true;
port 25,80,3535,465(with ssl), tls, ssl authentication,
what should I do? what should I try more, any ideas?
First of all, you're using a very old version of PHPMailer; get the latest.
I don't know where you got your code, but you've got the case of some vital properties wrong - I suggest you base your code on the examples provided with PHPMailer. In particular, subject
should be Subject
and port
should be Port
. When sending to localhost you don't need a username or password, so you don't need to set them. Similarly, Port
defaults to 25, so you don't need to set it.
You're not specifying a From address, and it looks like whatever address you're passing to addAddress
is invalid, so you're sending a message from nobody to nobody - and not surprisingly it's not going anywhere!
It looks like your message body is in Turkish (?), which will not work in the default ISO-8859-1 character set, so I suggest you switch to UTF-8 by setting $mail->CharSet = 'UTF-8';
.
Check your return values when calling addAddress to make sure the submitted value is valid before trying to send to it.
With these things fixed:
$name = $_POST['name'];
$email = $_POST['email'];
$mail = new PHPMailer;
if (!$mail->addAddress($email, $name)) {
die('Invalid email address');
}
$mail->isSMTP();
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug = 2;
$mail->Host = 'localhost';
$mail->Subject = 'Subject';
$mail->msgHTML('mail içeriği');
$mail->setFrom('me@example.com', 'My Name');
if ($mail->send()) {
echo 'Sent';
} else {
echo 'Error: '.$mail->Errorinfo;
}
这篇关于Godaddy phpmailer smpt配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!