2

我正在尝试在发送表单但没有任何事情发生时发送电子邮件。我使用 winHost 作为提供者。我试过制作一个单独的 .php 文件来测试 mail() 函数但没有雪茄 - mail('myemail','dfd','dsaf','dasfda');

这是我的邮寄设置-

    $to = $agentemail;
$subject = "";
$message = "";
$from = "";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);

如果您需要更多信息,请告诉我。

4

1 回答 1

0

正如@alfasin 所指出的,您需要遵循他提供给WinHost 知识库的第一个链接上的示例代码:

您需要将主机和用户名替换为您已设置的实际电子邮件帐户的详细信息。

<?php 
require_once "Mail.php"; 
$from = "Sender <postmaster@HostingAccountDomain.com>"; 
$to = "Recipient <user@HostingAccountDomain.com>"; 
$subject = "This is a test email sent via php"; 
$body = "This is a test email"; 

$host = "mail.HostingAccountDomain.com"; 
$username = "postmaster@HostingAccountDomain.com"; 
$password = "email_password"; 

$headers = array ('From' => $from, 
                  'To' => $to, 
                  'Subject' => $subject); 

$smtp = Mail::factory('smtp', 
                      array ('host' => $host, 
                             'auth' => true, 
                             'username' => $username, 
                             'password' => $password)
                      ); 
$mail = $smtp->send($to, $headers, $body); 
?> 
于 2012-08-22T08:25:22.203 回答