Jak zapobiec wysyłaniu wiadomości przez PHP mail () do spamu?
Używam funkcji mail () PHP do wysyłania e-maili (proces sendmail jest uruchomiony). Ale wszystkie maile będą spamować (w przypadku Gmaila). Próbowałem wielu sztuczek, które znalazłem w sieci, ale żaden nie działa, proszę powiedz mi o każdej sztuczce z pewnymi strzałami.
5 answers
Należy dodać nagłówki igieł:
Przykładowy kod :
$headers = "From: [email protected]\r\n";
$headers .= "Reply-To: [email protected]\r\n";
$headers .= "Return-Path: [email protected]\r\n";
$headers .= "CC: [email protected]\r\n";
$headers .= "BCC: [email protected]\r\n";
if ( mail($to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-08-10 13:34:17
Nie ma pewnej sztuczki. Musisz zbadać powody, dla których Twoje wiadomości są klasyfikowane jako spam. SpamAssassin zawiera stronę opisującą kilka wskazówek dla legalnych nadawców, aby uniknąć fałszywych alarmów . Zobacz także kodowanie Horror: więc chcesz wysłać jakiś e-mail (za pomocą kodu)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-05-09 09:44:37
Spróbuj PHP Mailer library .
Lub wysłać pocztę przez filtr SMTP przed wysłaniem.
Spróbuj również podać wszystkie szczegóły, takie jak FROM
, return-path
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-02-28 04:39:52
<?php
$subject = "this is a subject";
$message = "testing a message";
$headers .= "Reply-To: The Sender <[email protected]>\r\n";
$headers .= "Return-Path: The Sender <[email protected]>\r\n";
$headers .= "From: The Sender <[email protected]>\r\n";
$headers .= "Organization: Sender Organization\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n" ;
mail("[email protected]", $subject, $message, $headers);
?>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-10-19 22:03:02
$fromMail = 'set your from mail';
$boundary = str_replace(" ", "", date('l jS \of F Y h i s A'));
$subjectMail = "New design submitted by " . $userDisplayName;
$contentHtml = '<div>Dear Admin<br /><br />The following design is submitted by '. $userName .'.<br /><br /><a href="'.$sdLink.'"><b>Click here</b></a> to check the design.</div>';
$contentHtml .= '<div><a href="'.$imageUrl.'"><img src="'.$imageUrl.'" width="250" height="95" border="0" alt="my picture"></a></div>';
$contentHtml .= '<div>Name : '.$name.'<br />Description : '. $description .'</div>';
$headersMail = '';
$headersMail .= 'From: ' . $fromMail . "\r\n" . 'Reply-To: ' . $fromMail . "\r\n";
$headersMail .= 'Return-Path: ' . $fromMail . "\r\n";
$headersMail .= 'MIME-Version: 1.0' . "\r\n";
$headersMail .= "Content-Type: multipart/alternative; boundary = \"" . $boundary . "\"\r\n\r\n";
$headersMail .= '--' . $boundary . "\r\n";
$headersMail .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$headersMail .= 'Content-Transfer-Encoding: base64' . "\r\n\r\n";
$headersMail .= rtrim(chunk_split(base64_encode($contentHtml)));
try {
if (mail($toMail, $subjectMail, "", $headersMail)) {
$status = 'success';
$msg = 'Mail sent successfully.';
} else {
$status = 'failed';
$msg = 'Unable to send mail.';
}
} catch(Exception $e) {
$msg = $e->getMessage();
}
To działa dobrze dla me.It zawiera pocztę z obrazkiem i linkiem i działa dla wszystkich rodzajów identyfikatorów poczty. Wskazówka polega na doskonałym użyciu całego nagłówka.
Jeśli testujesz go z localhost, Ustaw poniżej przed sprawdzeniem:
Jak ustawić wysyłanie poczty z localhost xampp:
-
Skomentuj wszystko w
D:/xampp/sendmail/sendmail.ini
i wymień poniżej pod[sendmail]
Smtp_server=smtp.gmail.com smtp_port=587 error_logfile = error.log debug_logfile=debugowanie.log [email protected] auth_password=your-mail-password [email protected]
-
W
D:/xampp/php/php.ini
a. pod[funkcja poczty]
SMTP = smtp.gmail.com smtp_port = 587
B. set sendmail_from = [email protected]
c. uncomment sendmail_path ="\ " D:\xamp\sendmail\sendmail.exe\ " - t"
Stąd powinien wyglądać jak poniżej
sendmail_path = "\"D:\xamp\sendmail\sendmail.exe\" -t"
D. comment sendmail_path="D:\xamp\mailtodisk\mailtodisk.exe" Stąd powinien wyglądać jak poniżej
;sendmail_path="D:\xamp\mailtodisk\mailtodisk.exe"
E. mail.add_x_header=Off
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-03-28 10:36:21