Не отправляется email
Добрый день.
На сайте не отправляется email.
mail не работает. Пробовал SwiftMailer - тоже нет.
В чём может быть причина и как отправить сообщения и вложения?
Спасибо.
--------------------------------
$to = 'to@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: from@gmail.com' . "\r\n" .
'Reply-To: from@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
-------------------------------------------
mail('nobody@example.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');
--------------------------------------------
require_once 'mail/lib/swift_required.php';
$mailer = new Swift_Mailer(new Swift_MailTransport());
$message = Swift_Message::newInstance()
->setSubject('Order Entry') // Message subject
->setTo(array('maestrotwors@gmail.com' => 'Eric Hilse')) // Array of people to send to
->setFrom(array('agent.p.24.ru@gmail.com' => 'PAi Order Entry'))
->setBody('1234567890', 'text/html'); // Attach that HTML message from earlier
//->attach(Swift_Attachment::newInstance($pdf_content, 'design.pdf', 'application/pdf')); // Attach the generated PDF from earlier
//->attach(new Swift_Message_Attachment(new Swift_File($file), $filename));
// Send the email, and show user message
if ($mailer->send($message))
$success = true;
else
$error = true;
------------------------------------
Все эти варианты не работают. Если брать mail, то на других сайтах она работает. Прочитал, что может не быть smpt сервера или подкл неправильно. Что с этим можно делать?
Источник: Stack Overflow на русском