<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: yoursite.com';
$to = 'contact@yoursite.com';
$subject = 'Customer Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
Run Code Online (Sandbox Code Playgroud)
我试过创建一个简单的邮件表单.表单本身在我的index.html页面上,但提交单独的"谢谢你的提交"页面thankyou.php,其中嵌入了上面的PHP代码.代码提交完美,但从不发送电子邮件.请帮忙.
我正在处理该网站的联系表格.此联系表单通过PHP实现.我能够配置我的本地环境以实现此功能,但在部署到生产后,功能已经消失.
从我的角度来看,它不能在生产中工作的主要原因是它php.ini与本地机器上的配置不同.这里出现了几个问题:
php.ini在服务器上访问.php.ini可能会破坏一些东西,这将是非常糟糕的.我能找到的信息:
PHP 5.4.45 running as FastCGI application另外我的一个发现是(毫不奇怪)开始使用像Mailgun或Mandrill这样的第三方解决方案.Mandrill现在是Mailchimp的插件,因为我已经在这个项目中使用了Mailchimp,所以它非常有用.但我不想去第三方,因为该项目有一个服务器,只缺少一个正确的配置.
更新:
感谢@oleg_neumyvakin的回答,我发现间接的每域修改可以通过.user.ini配置完成,或者我可以通过Additional Configuration Directives字段访问Plesk .虽然该sendmail_path指令不适用于.user.ini,因为它只能在PHP_INI_SYSTEM- global中修改php.ini.
我的问题仍然存在:
php.ini配置.user.ini?所以,我在过去一个小时左右的时间里一直在研究这个邮件功能,但我不明白为什么它没有发送电子邮件!我已经尝试了多次,修改代码并试图使其完美,但我仍然没有收到测试电子邮件......
我的电子邮件中有 HTML,但这不是问题,因为我已经在没有 HTML 的情况下对其进行了测试。
我的PHP:
$to = $register_data['email'];
$subject = "Welcome!";
$body = '
<html>
<head>
<style>
body{
background-color: #FFF;
font-family: arial;
margin: 0;
padding: 0;
}
a{
color: inherit;
text-decoration: none;
}
.outer-email{
width: 80%;
height: auto;
margin: 0 auto;
}
.info-email{
width: 80%;
margin: 120px auto;
}
.outer-header h3{
font-size: 2.9em;
color: #151515;
margin: 0;
}
.inner-email{
margin-top: 20px;
}
.inner-email span{
font-size: 1.3em;
color: #151515;
}
</style>
</head>
<body>
<div class="outer-email">
<div class="info-email">
<div class="outer-header">
<h3>Welcome!</h3> …Run Code Online (Sandbox Code Playgroud) 我已经搜索了几个帖子,但没有运气.每个人都在使用postfix.但是当我浏览https://help.ubuntu.com/community/Postfix上的文本时
什么是邮件传输代理换句话说,它是一个邮件服务器而不是像Thunderbird,Evolution,Outlook,Eudora这样的邮件客户端,或者像Yahoo,GMail,Hotmail,Earthlink,Comcast,SBCGlobal.net,ATT这样的基于Web的电子邮件服务. .net等....如果您在一家名为Acme且拥有acme.com的公司工作,您可以为您的员工提供电子邮件地址@ acme.com.员工可以通过您的计算机发送和接收电子邮件,但不能让您的计算机一直运行.如果您的所有电子邮件地址都在域(@ gmail.com,@ yahoo.com),您不拥有(您不拥有Google)或不托管(acme.com),那么您根本不需要这些.
最后一行说你不能用gmail或者yahoo让它从localhost开始工作..!
谁能告诉我如何使用gmail SMTP在localhost上配置邮件服务器?我正在使用Ubuntu 14.
我之前尝试过的链接没有为我工作.测试下面列出的链接时没有错误或警告
https://askubuntu.com/questions/314664/sending-php-mail-from-localhost https://askubuntu.com/questions/228938/how-can-i-configure-postfix-to-send-all-email -through-my-gmail-account https://easyengine.io/tutorials/linux/ubuntu-postfix-gmail-smtp/ https://easyengine.io/tutorials/mail/postfix-debugging/
我已经使用php和pdo创建了登录和注册页面。
注册后,激活链接没有发送到注册邮箱。
我参考了这个链接How to configure XAMPP to send mail from localhost? 在堆栈溢出中,
我在 php 中没有 extension=php_openssl.dll。谁能告诉我,我在做什么?
我正在使用xampp1.7.4
我有一些问题,我不明白.这是我的代码
$this->load->library('email');
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->from('rudzstyle@yahoo.co.id', 'Your Name');
$this->email->to('rudzstyle@gmail.com');
$message = $data->nama_depan.'<br>'.$this->input->post('snk');
$this->email->subject($message);
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
Run Code Online (Sandbox Code Playgroud)
那2封电子邮件是有效电子邮件
调试器的结果就是这个
退出状态码:1无法打开Sendmail的套接字.请检查设置.无法使用PHP Sendmail发送电子邮件.您的服务器可能未配置为使用此方法发送邮件.
User-Agent:CodeIgniter日期:星期一,2014年6月2日07:53:21 +0200来自:"你的名字"返回路径:收件人:rudzstyle@gmail.com主题:=?iso-8859-1?Q?Riyanto test ?= =?iso-8859-1?Q ?? =回复:"rudzstyle@yahoo.co.id"X-Sender:rudzstyle@yahoo.co.id X-Mailer:CodeIgniter X-Priority:3(正常)消息ID:<538c1151179cb@yahoo.co.id> Mime版本:1.0
内容类型:text/plain; charset = iso-8859-1 Content-Transfer-Encoding:8bit
测试电子邮件类.
email ×6
php ×6
html ×2
codeigniter ×1
gmail ×1
html-email ×1
iis ×1
localhost ×1
pdo ×1
plesk ×1
postfix-mta ×1
ubuntu ×1
yahoo ×1