我正在使用此代码,这不会给我任何错误,也不会发送任何邮件。 这有什么值得注意的问题吗? 并没有通过我提供的SMTP详细信息发送。 我手动完成所有事情。
有人可以重写此代码以使用SMTP以及我所犯的错误吗?
<?php
require_once "Mail.php";
$Subject=T rim(stripslashes($_POST[ 'Subject']));
$Name=T rim(stripslashes($_POST[ 'Name']));
$Email=T rim(stripslashes($_POST[ 'Email']));
$EmailMe='admin@mail.com' ;
$Message=T rim(stripslashes($_POST[ 'Message']));
$smtp=M ail::factory( 'smtp',
array( 'host'=> 'host',
'port' => '#port',
'auth' => true,
'username' =>
'mymail@mail.com',
'password' => '********'
));
$mail_user = "<html>
<body style='font-size: 120%;'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' style='background:#e1f5fe;'>
<tr>
<td align='left' style='background:#2196F3;padding-left:5px;'><img src='path/to/image.png' width='50px' align='center' alt='' /><span style='color:#fff;font-size:20px;margin-top:5px;'>Title</span>
</td>
</tr>
</td>
<tr>
<td style='padding-left:5%;padding-right:5%'>
<p>Hi $Name,</p>
<p style='padding-left:3%;'>body for users</p>
<div style='background:#b3e5fc;'>
<p style='padding-left:1%;'>Message : </p>
<p style='padding-left:2%;padding-bottom:2px;'>$Message</p>
</div>
<p>Regards,</p>
<p style=''><b>Admin</b>
</p>
</td>
</tr>
</table>
<br>
</body>
</html>";
$mail_me = "<html>
<body style='font-size: 120%;'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' style='background:#e1f5fe;'>
<tr>
<td align='left' style='background:#2196F3;padding-left:5px;'><img src='path/to/image.png' width='50px' align='center' alt='' /><span style='color:#fff;font-size:20px;margin-top:5px;'>Titile</span>
</td>
</tr>
</td>
<tr>
<td style='padding-left:5%;padding-right:5%'>
<p>Hi $Name,</p>
<p style='padding-left:3%;'>body for me</p>
<div style='background:#b3e5fc;'>
<p style='padding-left:1%;'>Message : </p>
<p style='padding-left:2%;padding-bottom:2px;'>$Message</p>
</div>
<p>Regards,</p>
<p style=''><b>Admin</b>
</p>
</td>
</tr>
$Email
</table>
<br>
</body>
</html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: ME <mymail@mail.com> \r\n";
$headers .= "Reply-To:
<admin@mail.com> \r\n";
$headers .= "Return-Path: mymail@mail.com";
$headers .= "X-Mailer: PHP \r\n";
$success = mail($Email, $Subject, $mail_user, $headers);
mail($EmailMe, $Subject, $mail_me, $headers);
if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=/thanks\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=/error\">";
}