У меня есть проект, в котором я должен отправлять 100-200 писем пользователям, но у каждой почты есть другой токен для каждого пользователя. У меня есть электронная почта, размещенная на godaddy.Ошибка Php Mailer - Godaddy Smtp
Итак, я искал, чтобы отправить электронное письмо с помощью phpmailer. Ниже приведен скрипт, который я тестирую, но он продолжает давать мне эту ошибку.
SMTP ERROR: Не удалось подключиться к серверу: Соединение отказано (111) Ошибка SMTP connect(). https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Ошибка Mailer: сбой SMTP connect(). https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
<?php
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require 'mailm/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
$mail->DKIM_domain = '127.0.0.1';
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "smtpout.secureserver.net";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 465;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "[email protected]";
//Password to use for SMTP authentication
$mail->Password = "Mypassword";
$mail->SMTPSecure = 'ssl';
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'IT Helpdesk');
//Set an alternative reply-to address
//$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'IT Helpdesk');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
//Replace the plain text body with one created manually
$mail->Body = 'This is a plain-text message body';
//Attach an image file
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Этот сценарий я нашел на блоге.
Любые альтернативы этому также приветствуются. Моя цель - отправить 200 электронных писем из моей учетной записи электронной почты godaddy, но каждое электронное письмо имеет отдельный токен, который извлекается из базы данных, а затем вставляется в тело письма и отправляется пользователю.
но мне кажется, что проблема не связана с конкретным кодом, но связана с «авторизацией SMTP». как вы установили соединение SMTP, и почтовый сервер настроен правильно? – Farside
Помимо проблемы с автоответчиком GoDaddy, введите свой код в [пример списка рассылки, предоставленный wth PHPMailer] (https://github.com/PHPMailer/PHPMailer/blob/master/examples/mailing_list.phps). – Synchro