简体   繁体   English

通过php发送邮件不起作用

[英]Sending Mail through php Not working

I have been trying to Make an email confirmation for my site. 我一直在尝试通过电子邮件确认我的网站。 People can register with no problem, and everything registers into the database, but it does not send an email. 人们可以毫无问题地进行注册,并且所有内容都注册到了数据库中,但是它不会发送电子邮件。 I tried it normally, and it gave me some error about the smtp server, so someone said i should try SurgeMailer. 我正常尝试了一下,这给我关于smtp服务器的一些错误,所以有人说我应该尝试SurgeMailer。 I downloaded it, and now the emails actually say they sent, but the email never receives them. 我下载了它,现在电子邮件实际上说它们已发送,但电子邮件从未收到。 Any help would be great! 任何帮助将是巨大的! Heres the code for sending the email. 这是用于发送电子邮件的代码。

/*Send Email here*/
$to=$Email;

$subject="Newgenstudios Account Confirmation";

/*From*/
$header="From:Newgenstudios <noreply@newgenstudios.com>";

/* Your message */   /*Not Finished */
$message = "<h3>Welcome to the site ".ucfirst(strtolower($First_Name))."!</h3>
<p>To complete your account registration, you must activate your account. Click on the link below or paste it into the URL to activate your account.</p>
<p><a href='http://localhost/confirmation.php?passkey=$confirm_code'>Activate Now!</a </p>
<p>Once your account has been activated, you may log in at anytime using the information you supplied below:<br />
<strong>Email: </strong>$Email<br />
<strong>Password: </strong>$Password</p>
<p>Other Information:</p>
<strong>Name: </strong>$First_Name<br />
<strong>Phone: </strong>$Phone<br />
<p>Thank you for registering and see you on the site!</p>
<p>Did you not register? Then please disregard this message.</p>";

/* Send Email */
$sentmail = mail($to,$subject,$message,$header);
}

/*If not found*/
else {
echo "Not found your email in our database";
}

/* email succesfully sent */
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}
?>

1- try To use this mail function . 1-尝试使用此邮件功能。

2- write " from value " as valid email related to your domain, like : noreply@domain.com 2-将“来自价值”作为与您的域相关的有效电子邮件,例如:noreply@domain.com

3- if steps not work please call your hosting I guess mail() function blocked by them . 3-如果步骤不起作用,请致电您的托管我想mail()函数被它们阻止了。

function send_mail($to,$from,$subject,$msg){
        // message
        $message = '
        <html>
        <head>
          <title>Message</title>
        </head>
        <body dir="rtl">
        <p align="right">'
        . $msg .
        '</p>
        <br>

        </p>
        </body>
        </html>
        ';

        // To send HTML mail, the Content-type header must be set
        $headers  = 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-type: text/html; charset=utf-8' . "\n";

        // Additional heade rs
        $headers .= "From: ".$from . "\n";
        //$headers .= 'Bcc: info@domain.co.uk' . "\n";

        // Mail it
        return mail($to, '=?windows-1256?B?'.base64_encode($subject).'?=', $message, $headers);
    }

I'd suggest using a Gmail account to send an email, that's the quickest one to set up for me. 我建议使用Gmail帐户发送电子邮件,这是为我设置的最快的帐户。 (just google 'send php gmail email'). (只是google'发送php gmail电子邮件')。 And also, don't forget to check spam folder. 而且,别忘了检查垃圾邮件文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM