所以我現在已經嘗試了兩天來擺脫這個問題。如前所述,代碼在我的 xampp apache localhost 上運行良好。電子郵件立即發送。但是,在我擁有的域上,一旦我按下提交,它就會加載和加載,并且在 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_once('mail.php'); 當然,在 index.php 中,表單所在的位置。mail.php 看起來像這樣:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
// 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 protected]'; //Sets SMTP username
$mail->Password = 'example'; //Sets SMTP password
$mail->SMTPSecure = 'tls'; //Sets connection prefix. Options are "", "ssl" or "tls"
$mail->setFrom( '[email protected]', 'example' ); //Sets the From email address for the message
$mail->addAddress( '[email protected]' );
$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();
}
}
?>
電子郵件名稱和密碼是故意更改的。我真的束手無策。那是我的第一個 Hompeage,其他一切都很好。為什么它在 5 分鐘后發送電子郵件,但再次顯示 503 而不是 index.php?謝謝你。
uj5u.com熱心網友回復:
我認為您應該將SMTP 埠和 SMTP Secure 更改為:
$mail->Port = '465';
$mail->SMTPSecure = 'ssl';
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/442573.html
