PHPMailer:在本地主机上工作,单击域上的"submit"按钮后卡住,出现错误503,电子邮件在4分钟后到达



所以我已经尝试了两天来解决这个问题。如前所述,该代码在我的xamp-apachelocalhost上运行得非常好。电子邮件会立即发送。然而,在我拥有的域上,一旦我按下提交,它就会加载,大约5分钟后就会超时,或者更确切地说是一个"暂停";503 Servive不可用";。我已经检查了我的本地PHP错误日志,一切都很好。不过,我无法访问服务器上的错误日志。

这是表单的代码:

<div class="form-group">
<label>Ihr Name</label>
<input type="text" name="name" placeholder="Vorname Nachname" class="form-control"  />
</div>
<div class="form-group">
<label>Ihre E-Mail Address</label>
<input type="email" name="email" class="form-control" placeholder="IhreEmail@server.com"  />
</div>
<div class="col-md-6">
<div class="form-group">
<label>Ihre Nummer</label>
<input type="text" name="mobile" placeholder="Ihre Mobile 079 *** ** **" class="form-control" required/>
</div>
<hr/>
<div class="form-group">
<label><i class="far fa-file"></i>Ihr Dokument für die Übersetzung</label>
<input type="file" name="resume" accept=".doc,.docx,.pdf,.jpg,.bmp"/>
</div>
</div>
<div class="form-group">
<label>Ihre Nachricht</label>
<textarea name="additional_information" placeholder="Welchen Service wünschen Sie? Wie sollen wir in Kontakt treten?" class="form-control" required rows="8"></textarea>
</div>
<div class="form-group" align="center">
<input type="submit" name="submit" value="Senden" class="btn btn-lg btn-success"/>
</div>
</form>

有一个include_one('mail.php'(;当然是在index.php中,表单所在的位置。mail.php如下所示:

<?php

use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerSMTP;
use PHPMailerPHPMailerException;
// HIDE ALL ERRORS
//error_reporting(0);
//ini_set('display_errors', 0);

$message = '';

if ( isset( $_POST['submit'] ) ) {

if ( isset( $_FILES['resume']['name'] ) && $_FILES['resume']['name'] != "" ) {
$path = 'upload/' . $_FILES['resume']['name'];
//print_r($path);
print_r( $_FILES );
move_uploaded_file( $_FILES["resume"]["tmp_name"], $path );
} else
$_FILES = NULL;
$message = '
<h3 align="center">Applicant Details</h3>
<table border="1" width="100%" cellpadding="5" cellspacing="5">
<tr>
<td width="30%">Name</td>
<td width="70%">' . $_POST["name"] . '</td>
</tr>

<tr>
<td width="30%">Email Address</td>
<td width="70%">' . $_POST["email"] . '</td>
</tr>
<tr>
<td width="30%">Phone Number</td>
<td width="70%">' . $_POST["mobile"] . '</td>
</tr>
<tr>
<td width="30%">Additional Information</td>
<td width="70%">' . $_POST["additional_information"] . '</td>
</tr>
</table>
';
require 'vendor/phpmailer/phpmailer/src/PHPMailer.php';
require 'vendor/phpmailer/phpmailer/src/SMTP.php';
require 'vendor/phpmailer/phpmailer/src/Exception.php';
require 'vendor/autoload.php';
$mail = new PHPMailer( true );
$mail->IsSMTP(); //Sets Mailer to send message using SMTP
// ADD YOUR DETAILS HERE
//$mail->Host = 'smtp.gmail.com'; //Sets the SMTP hosts of your Email hosting
$mail->Host = 'smtp.iway.ch '; //Sets the SMTP hosts of your Email hosting, this for Godaddy
$mail->Port = '587'; //Sets the default SMTP server port
$mail->SMTPAuth = true; //Sets SMTP authentication. 
$mail->Username = 'email@email.com'; //Sets SMTP username
$mail->Password = 'example'; //Sets SMTP password
$mail->SMTPSecure = 'tls'; //Sets connection prefix. Options are "", "ssl" or "tls"
$mail->setFrom( 'email@email.com', 'example' ); //Sets the From email address for the message
$mail->addAddress( 'example@server.com' );
$mail->SMTPDebug = 0;
$mail->WordWrap = 50;
$mail->IsHTML( true ); //Sets message type to HTML
if ( isset( $_FILES['resume']['name'] ) && $_FILES['resume']['name'] != "" ) {
$mail->AddAttachment( $path ); //Adds an attachment from a path on the filesystem
}
$mail->Subject = 'Emaple Mail'; //Sets the Subject of the message
$mail->Body = $message; //An HTML or plain text message body
try {
$mail->send();
header( "Refresh:3; url=index.php" );
exit();
} catch (phpmailerException $e) {
echo $e->errorMessage();
echo $e->getMessage();
}
}
?>

电子邮件名称和PW是故意更改的。我真是束手无策。这是我的第一次Hompeage,其他一切都很好。为什么它在5分钟后发送电子邮件,但再次显示503而不是index.php?非常感谢。

我认为您应该将SMTP端口和SMTP安全更改为:

$mail->Port = '465';
$mail->SMTPSecure = 'ssl';

相关内容

  • 没有找到相关文章

最新更新