PHP mail () Multipart / Alternative for HTML and plain text messages

I use the following code to send Multipart / Alternative HTML email and plain text. Emails send subtle content, but some of them end up in spam filters. This is the code I'm using.

$notice_text = "This is a multi-part message in MIME format."; $plain_text = "Some Plain Text Here\n\n"; $html_text = '<html><head><title>Sample HTML Email</title></head><body>'; $html_text .= '<p>Some text will go here.</p>'; $html_text .= '<p><img src="http://www.mydomain.com/img/offers.jpg" /></p>'; $html_text .= '<p>Can\'t see the images? <a href="http://www.mydomain.com/print_offer.php?promo=' . $promo_code . '">Click here</a></p>'; $html_text .= '</body></html>'; $semi_rand = md5(time()); $mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand"; $mime_boundary_header = chr(34) . $mime_boundary . chr(34); $from = "Test Email < testemail@testemail.com >"; $subject = "Get Your Offers Here"; $body = "$notice_text --$mime_boundary Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit $plain_text --$mime_boundary Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit $html_text --$mime_boundary--"; mail($email, $subject, $body, "From: " . $from . "\n" . "bcc: " . $bcc . "\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative;\n" . " boundary=" . $mime_boundary_header); 

What makes it enter spam filters? When I send an email in plain text, it does very well only when I send an HTML email that they receive. Any help would be greatly appreciated. Can I add more to the headers to help prevent spam filtering?

+5
source share
2 answers

Many spam filters use an aggregate scoring system to decide if an incoming message is spam. Individual spam problems may slip, but if several of them are present in a particular email, the threshold is reached and the message is reset.

In your post, I see several things that can increase your result:

Theme: "Get your suggestions here"

Solution: Try to include specific text about the content of your email and consider specifying the name of your company.

and

From: "Test Email: testemail@testemail.com ";

Solution: Use a real email address. In addition, make sure that the server from which you send the message is configured correctly (see SPF )

and

Content: Unknown

Solution: Make sure your content is specific and relevant. Make sure the links are associated with the domain from which the email was sent. Avoid using too many β€œspammy” keywords (β€œoffer,” β€œfree,” β€œl @@ k,” etc.).

You can perform a smell test on your own emails. Remove all links to your company and products and enter the general conditions. Review the result to see if the message was deleted if it arrived in your inbox.

+5
source

A direct link to your image file is also very high on spamdar.

+2
source

Source: https://habr.com/ru/post/891580/


All Articles