Godaddy phpmailer smpt configuration

微笑、不失礼 提交于 2019-12-02 10:22:00

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;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!