想通过wordpress发送电子邮件

时间:2014-05-26 17:25:47

标签: php wordpress forms email

我是wordpress的新手,我刚刚在我的godaddy服务器上安装了wordpress。我想在wordpress页面上创建一个表单,用户将在其中输入详细信息,名称和密码。当用户点击表单的提交按钮时,我希望wordpress向我发送一封电子邮件,其中包含用户在表单中输入的详细信息。请帮帮我。

3 个答案:

答案 0 :(得分:1)

我认为最好的解决方案是使用插件。有许多插件可以帮助您创建联系表单,该表单还会向您发送包含详细信息的电子邮件。 Contact Form 7很容易设置和使用。 我希望有所帮助。

答案 1 :(得分:1)

有一些插件,不确定你是否想要它。但如果你不这样做,你可以自己做。

如果你想自己做:

这是请求调用的文件(通常是AJAX请求):

<?php 

$client_email = $_POST["user_email"];
$client_email = (string) $client_email;
include('Mail.php');

$recipients = 'email@gmail.com';  
$headers['From']    = 'from@gmail.com'; 
$headers['To'] = 'email@gmail.com';
$headers['Subject'] = "subject";
$body = "This is the content" ;

// Define SMTP Parameters
$params['host'] = 'ssl://smtp.gmail.com';
$params['port'] = '465';
$params['auth'] = 'PLAIN';
$params['username'] = 'from@gmail.com';
$params['password'] = 'yourpassword';

//$params['debug'] = 'true';

// Create the mail object using the Mail::factory method
$mail =& Mail::factory('smtp', $params);

// Send the message
$mail->send($recipients, $headers, $body);

备注

答案 2 :(得分:0)

您应该使用wp_mail()函数:http://codex.wordpress.org/Function_Reference/wp_mail