ich diesen Code auf meinem Server verwende Mail zu senden, aber nicht richtig reagierenSMTP -> ERROR: Fehler beim Server verbinden: Connection refused (111) mit Zoho Mail
<?php
function smtpmailer($to, $subject, $body)
{
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.zoho.com';
$mail->Port = 587;
$mail->Username = "[email protected]";
$mail->Password = "********";
$mail->SetFrom("[email protected]", 'af');
$mail->Subject = $subject;
$mail->Body = $body;
$mail->isHTML(true);
$mail->AddAddress($to);
$mail->headers = "Content-type: text/html; charset=utf-8 \r\n";
$mail->headers = "Content-type: image";
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
echo $error;
$error_no = 0;
} else {
$error_no = 1;
}
return $error_no;
}
if(isset($_POST['Submit']))
{
$name = $_POST['name'];
$email=$_POST['email'];
$msg = $_POST['comment'];
$error = $nameErr = $emailErr = $msgErr = "";
if(empty($name) && empty($email) && empty($msg))
{
$error ="please fill all fields";
}
else
{
if($name == "")
{
$nameErr = "Please enter your name";
}
else
{
if(!preg_match("/^[a-zA-Z ]*$/",$_POST['name']))
{
$nameErr = "only letters and white spaces are allowed";
}
}
if($email == "")
{
$emailErr = "please enter your email";
}
else
{
if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid Email Id";
}
}
}
if(empty($error) && empty($nameErr) && empty($emailErr) && empty($msgErr))
{
$message = '';
$message .= '
<p>Hello,</p>
<h4>We have recicved new contact request. Follwoing are detials. </h4>
<table border=0>
<tr><td>Name -- </td><td>'.$name.'</td></tr>
<tr><td>Email ID -- </td><td>'.$email.'</td></tr>
<tr><td>Message -- </td><td>'.$msg.'</td></tr>
</table>
<p>Reagrds, <br/>Flxpert Team</p>';
$to = '[email protected]';
$sub = 'New contact request has logged.';
$to1=$email;
$subject1="Contact Successfull.";
$msg1 = '';
$msg1 = '<p>Hello '.ucfirst($name).',</p>
<table border=0>
<tr>
<td>Your contact request has successfully submitted. We will contact you as soon as possiable.</td>
</tr>
</table>
<p>Reagrds, <br/>Flxpert Team</p>';
smtpmailer($to, $sub, $message);
if(smtpmailer($to1, $subject1, $msg1)){
$success="Your contact request has successfully submitted. We will contact you as soon as possiable. ";
} else{
$error="Something went wrong... ";
}
}
}
?>
versuchen Sie, Ihren Code lesbarer zu machen. Sind Sie sicher, dass Ihr Passwort korrekt ist? –
sein Aussehen wie Sie Code ist nicht vollständigen Code veröffentlicht. Bitte geben Sie den vollständigen Code mit dem richtigen Format an –