简体   繁体   English

使用PHP发送回复邮件

[英]Sending a reply mail using PHP

I am sending a reply mail using PHP to those who send a mail to me. 我正在使用PHP向那些向我发送邮件的人发送回复邮件。

My problem is when I send an email, it sits in the spam folder. 我的问题是,当我发送电子邮件时,它位于垃圾邮件文件夹中。 What do I do in order to deliver mail correctly. 我该怎么做才能正确传递邮件。 What should I do? 我该怎么办?

My code 我的密码

<?php
    $email_id="welcome@gmail.com";
    $recipient = "@gmail.com"; //Recipient
    $mail_body = $message; //Mail body
    $subject = "Subject ".$Name.""; //Subject
    $header = "From: ". $Name . " <" . $email . ">\r\n"; //Optional headerfields
    $header .='Content-type: text/plain; charset=utf-8'."\r\n";
    mail($recipient, $subject, $mail_body, $header); /mail command :)
?>

Make sure you're populating the From, Reply-To, Sender, Return-Path, and Errors-To headers with the sending e-mail address. 确保使用发送电子邮件地址填充“发件人”,“答复至”,“发件人”,“返回路径”和“错误至”标题。 There are so many reasons e-mails may be filtered as spam, though - your ISP may be blocked, the contents of the message may contain things that get it flagged, etc. 电子邮件被过滤为垃圾邮件的原因有很多,例如-您的ISP可能被阻止,邮件的内容可能包含将其标记为垃圾邮件的内容,等等。

The problem is not necessarily in your code. 问题不一定在您的代码中。 One possibility is that your server's mail transfer agent is misconfigured - I've experienced this issue once. 一种可能是服务器的邮件传输代理配置错误-我曾经遇到问题。 Worth checking. 值得检查。

The problem is not coming from your code. 问题不在于您的代码。 You may need to configure your service. 您可能需要配置服务。 In order to be accepted by most of the email service providers, you should setup a DomainKey or a Sender Id . 为了被大多数电子邮件服务提供商所接受,您应该设置DomainKeySender Id

You should also make sure that your IP address is not blacklisted if you are running this code on a dedicated server. 如果在专用服务器上运行此代码,还应确保未将IP地址列入黑名单。

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

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