I am getting the following intermittent error that has started in the last 24 hours from gmail servers (When sending to gsuite accounts or gmail accounts). It doesn't happen to all messages. Even the same message failed once and then worked later. I am looking for a way to fix this. I am not sure if it is the headers or something gmail did as a mistake.
I have a dedicated IP with mailgun and aren't getting any other errors except gmail.
This is the error:
5.7.1 [69.72.33.194 11] Our system has detected that this message is 5.7.1 not RFC 5322 compliant: 5.7.1 'From' header is missing. 5.7.1 To reduce the amount of spam sent to Gmail, this message has been 5.7.1 blocked. Please visit 5.7.1 https://support.google.com/mail/?p=RfcMessageNonCompliant 5.7.1 and review RFC 5322 specifications for more information. p18si54042ood.13 - gsmtp
Code to send email: (Via postfix using mailgun)
$lead_email = BCC_EMAIL;
$cc_email = LEAD_CC_NOTIFICATION_EMAIL;
$message = <<<MSG
<p>Hi PHP POS Admin,</p>
<p>You have received a TRIAL CONVERSION from the customer below: </p>
<ul>
<li>Company: $data[company]</li>
<li>Name: $data[name]</li>
<li>E-Mail: $data[email]</li>
<li>Phone: $data[phone]</li>
<li>Provider: $data[payment_provider]</li>
<li>Address: <strong>$data[country]</strong> $data[address_1] $data[address_2] $data[city] $data[state], $data[zip]</li>
<li>IP Address: $data[ip_address]</li>
<li>IP Address Location: $data[ip_geo]</li>
</ul>
Regards<br>
</p>
MSG;
$from = $lead_email;
$subject = 'SUBJECT';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "From: ".$from . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
mail($lead_email, $subject, $message, $headers);
Raw MIME:
Received: by REDACTED (Postfix, from userid 48)
id 91F58812D2; Tue, 19 May 2020 17:51:59 +0000 (UTC)
To: REDACTED
Subject: REDACTED
X-PHP-Originating-Script: 500: REDACTED
MIME-Version: 1.0
From: example#example.com
Content-type: text/html; charset=UTF-8
Message-Id: < REDACTED >
Date: Tue, 19 May 2020 17:51:59 +0000 (UTC)
<p>Hi PHP POS Admin,</p>
<p>You have received a TRIAL CONVERSION from the customer below: </p>
<ul>
<li>Company: REDACTED</li>
<li>Name: REDACTED </li>
<li>E-Mail: REDACTED </li>
<li>Phone: REDACTED </li>
<li>Provider: braintree</li>
<li>Address: <strong> REDACTED </strong> , REDACTED </li>
<li>IP Address: REDACTED </li>
<li>IP Address Location: , , </li>
</ul>
Regards,<br>
PHP Point Of Sale Team
</p>
I ended up using phpmailer as this manages all the headers. So far it has worked
Related
I've been using a PHPMailer script for years sending emails to my group. Everything was working great up until last week. Now when I send an email the multi-part is fully displayed as plain text. Here is my PHP script:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '/fullpath/public_html/tmp/PHPmailer.php';
require '/fullpath/public_html/tmp/SMTP.php';
require '/fullpath/public_html/tmp/Exception.php';
$body = $_POST['msgText'];
$mail = new PHPMailer();
$mail->setFrom('MY WEB SITE EMAIL', 'ME');
$mail->addReplyTo('MY EMAIL', 'ME');
$mail->addAddress('MY EMAIL', 'ME');
$mail->Subject = $_POST['subjectText'];
$mail->isHTML(true);
$mail->SMTPDebug = 2;
$mail->Body = $body;
$mail->CharSet = 'UTF-8';
$a = $_POST['toText'];
// For output display
echo "<!DOCTYPE html>\n<html lang=en><head><title>My Test PHP Mailer</title></head>\n<body>\n<h1>My Test PHP Mailer</h1>\n<h4>Sending Emails to:</h4>\n<ul>";
foreach ($mail->parseAddresses($a) as $address) {
$mail->addBCC($address['address'], $address['name']); // for release
// $mail->addAddress($address['address'], $address['name']); // for testing
echo "<li>Name: " . $address['name'] . " - address: [" . $address['address'] . "]</li>\n";
}
echo "</ul>\n";
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
echo "<br>" . $_POST['toText'];
} else {
echo "<form><textarea name=ta>" . $body . "'></textarea></form>";
}
echo "<p><a href='index.php'>Back to index.php</a></p>\n</body>\n</html>";
?>
And my email is showing up like this:
This is a multi-part message in MIME format.
--b1_5S1Pr6ILOHSPuOiGgJGQzPfIPsBjnsOmX6MAuoro
Content-Type: text/plain; charset=us-ascii
Good luck to all, and thanks for participating,
--b1_5S1Pr6ILOHSPuOiGgJGQzPfIPsBjnsOmX6MAuoro
Content-Type: text/html; charset=us-ascii
<HTML><HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></HEAD>
<BODY bgColor="#ffffff">
<div style="max-width:800px;border:1px solid #666666; padding:9px; background-color:white;">
<DIV><FONT face="Arial" color="#000080" size="6"><B><I>NFL
<FONT color="#C80000">Challenge</FONT> 2022</I></B></FONT></DIV>
<DIV><FONT face="Arial, Helvetica" color="#ff0000" size="4"><B>Hey Sportsfans,</B></FONT></DIV>
<br>
<DIV><FONT face="Arial" size="2">Good luck to all, and thanks for participating,</FONT></DIV>
<br>
</DIV></div>
</BODY>
</HTML>
--b1_5S1Pr6ILOHSPuOiGgJGQzPfIPsBjnsOmX6MAuoro--
I haven't made any changes in the last week. Why would the emails be sent as simply text and not do the multi-part encoding? This output is the same for all mail clients.
I have searched the internet for the last week and can't find anything that helps. I did update to the latest version of PHPMailer to see if that would fix the problem, but it still remains. I want the email to be sent as HTML and not have the raw details going out to all my friends.
Any suggestions, opinions or dumb looks appreciated.
==============[ UPDATE ]=================
I was asked to specify more details on my problem. When I tried initially, Stackoverflow gave me an error that this was a spam submission. So I'm going to try again and redact some details to hopefully avoid that error.
First - the email is being sent using PHPMailer 6.1.1
Second - the email clients receiving the emails that I have been able to test are: Gmail, Outlook, and Yahoo Mail.
Third - I was asked to share the raw source of the email (this is where I hope I can avoid the 'spam' error).
This is the last working email I sent, as reported from Gmail "show original":
Subject: NFL Challenge 2022 - Week 18 Reminder
X-PHP-Script: xxxxxxxxxxxx/file.php for 162.252.247.224
X-PHP-Originating-Script: 1002:PHPmailer.php
Date: Fri, 6 Jan 2023 01:02:03 +0000
From: NFL Challenge <me#myserver>
Message-ID: <GdssaiyhOGwE5lgWdOnRMleJbhKIfeZQPc4TpJB74#www.starbase47.com>
X-Mailer: PHPMailer 6.1.1 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="b1_GdssaiyhOGwE5lgWdOnRMleJbhKIfeZQPc4TpJB74"
Content-Transfer-Encoding: 8bit
X-CMAE-Envelope: MS4xfNLwjf/lI+ECbHq2uNTaPo2pDBlT0LgWHZfm+1mtCGh1qLdFoViGjgSHemmT9C8buRCOrt1A4pAvnGulYNkPiO6cJBSDRVv2s9yqB3tUM/GOH02Idbpt 4uA8x2WkhDDGrE1gBk+cE3ZeAWqXwfQWDQznYq5N7InVD9s4UlutNmMlACjSidhnEIrzVJHFZsR3gvGOSiEZDf8Xg4jjk51comuqnF4hLvF9slMWKexfPYfp 6Xxsb7BqWoHfbmSTB0WrMR6wzG3e0ybFGe3HDiMIPPCsHfCHUzaLjXMSfUCI8xcbnScfTz9t/00yLtSwLj4nu+sganzgBI433vpvFj28Aw7bDlm4K0iERspz shEaDRpZwHKD44xwCTSsa/zjvrXAdsOo39EuWLtn25QSOT3QYuEKmpe4M1mMGS6BH/oP3rxUGu89rDzc7fBcav7MtnNLI7Wz2kWAnBvuyrZWhKM/vBzLUUd/ uWtz/nhTNzzItSy1rm8ObR+cm6RuWil0uilXF9nF/gg5TzFOixzNgTuvexbclXCl198ACnro7gQfxMM47NeRuZkhQUjjOuhm+k0TeJyRKWD7S1ujA3qfndH/ 8LI=
--b1_GdssaiyhOGwE5lgWdOnRMleJbhKIfeZQPc4TpJB74
Content-Type: text/plain; charset=us-ascii
NFL
Challenge 2022
Hey Sportsfans, ...
This is the source of the email that didn't format correctly, again from Gmail "show source".
Subject: NFL Challenge 2022 - Playoffs Test
X-PHP-Script: www.starbase47.com/mytest_mail.php for 162.252.247.224 X-PHP-Originating-Script: 1002:PHPmailer.php
Date: Thu, 12 Jan 2023 21:33:09 +0000 From: NFL Challenge <me#myserver> Message-ID: <5S1Pr6ILOHSPuOiGgJGQzPfIPsBjnsOmX6MAuoro#www.starbase47.com> X-Mailer: PHPMailer 6.1.1 (https://github.com/PHPMailer/PHPMailer) MIME-Version: 1.0 Content-Type: multipart/alternative;
boundary="b1_5S1Pr6ILOHSPuOiGgJGQzPfIPsBjnsOmX6MAuoro" Content-Transfer-Encoding: 8bit
Message-Id: <E1pG5C9-0006pY-1D#192.222.167.72.host.secureserver.net>
From: me#myserver
X-CMAE-Envelope: MS4xfI/De/t+kmwbb6eY2xWVi89UxsAiJ5qMwBEnzqpJBSwnrpHKLYrLpRjMnFUNxqZVwAckeapMXSEzXsK71DSiMO5WP0VZxM0iNr0qMiD/lOxS2Sp5+Vb0 4nUe/KgwmKZcA8v6BUI5N0fFqt5Ha2nrzlg4ouBiPrZTTYgrTQ+UQoHWyWWl/LWrhDX5AUYdRYL/DI0Q7u5H+LjjhdKhAOdTeKAPsa+EEkVMxWbX/z27TF2m jzATQVQbCe7u4en0+gEgDg==
This is a multi-part message in MIME format.
--b1_5S1Pr6ILOHSPuOiGgJGQzPfIPsBjnsOmX6MAuoro
Content-Type: text/plain; charset=us-ascii
NFL
Challenge 2022
Hey Sportsfans, ...
If you need me to share more details (like from another client, or the raw PHPMailer code that I have on my server) please let me know.
Thank you in advance - Einstein47
I have a script for sending HTML email messages which works fine for text and html tags but I cannot figure out why my images wont display.
function sendHtmlEmail($email, $content, $message_content){
$to = "$email";
$subject = "AeroBLOG - $content";
$message = "
<HTML>
<HEAD>
<TITLE>$subject</TITLE>
<META http-equiv='content-type' content='text/html; charset=utf-8' />
<STYLE>
</HEAD>
<BODY>
$message_content
</BODY>
</HTML>
";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
$headers .= 'From: <do-not-reply#aeroblog.tk>' . "\r\n";
if(mail($to,$subject,$message,$headers)){return true;}else{return false;}
}
call to function:
$message="<IMG src=\"http://aeroblog.tk/img/VerificationEmail.png\" alt=\"copy & paste this link into your browsers navigation bar: http://.........\" width=\"1024px\" height=\"768px\">";
sendHtmlMail("myemail#example.com","Subject",$message);
Here is the complete email which is returned including headers:
Delivered-To: oneal.michaels#gmail.com
Received: by 10.182.154.35 with SMTP id vl3csp1831038obb;
Sun, 6 Dec 2015 16:26:01 -0800 (PST)
X-Received: by 10.13.213.14 with SMTP id x14mr19939281ywd.229.1449447961510;
Sun, 06 Dec 2015 16:26:01 -0800 (PST)
Return-Path: <a6602671#srv10.000webhost.com>
Received: from postlady.000webhost.com (smtp5.000webhost.com. [31.170.163.248])
by mx.google.com with ESMTP id j63si14327386ywf.69.2015.12.06.16.26.01
for <oneal.michaels#gmail.com>;
Sun, 06 Dec 2015 16:26:01 -0800 (PST)
Received-SPF: pass (google.com: domain of a6602671#srv10.000webhost.com designates 31.170.163.248 as permitted sender) client-ip=31.170.163.248;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of a6602671#srv10.000webhost.com designates 31.170.163.248 as permitted sender) smtp.mailfrom=a6602671#srv10.000webhost.com
Received: by postlady.000webhost.com ([000webhost.com Mail Server], from userid 99)
id 59C5B602FC; Mon, 7 Dec 2015 00:26:01 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
postlady.000webhost.com
X-Spam-Level: ****
X-Spam-Status: No, score=4.6 required=7.0 tests=BODY_URI_ONLY,
HTML_IMAGE_ONLY_08,HTML_IMAGE_RATIO_02,HTML_MESSAGE,HTML_SHORT_LINK_IMG_1,
MIME_HTML_ONLY,TVD_RCVD_SPACE_BRACKET,T_RP_MATCHES_RCVD autolearn=disabled
version=3.3.2
Received: from srv10.000webhost.com (srv10.000webhost.com [31.170.160.74])
by postlady.000webhost.com ([000webhost.com Mail Server]) with ESMTP id 9924B602FB
for <oneal.michaels#gmail.com>; Mon, 7 Dec 2015 00:25:26 +0000 (UTC)
Received: by srv10.000webhost.com (Postfix, from userid 6602671)
id 929B018B5C7; Sun, 6 Dec 2015 19:25:26 -0500 (EST)
To: oneal.michaels#gmail.com
Subject: AeroBLOG - Verification Email: Welcome, MikeIsMyName
X-PHP-Script: aeroblog.tk/sendVerificationEmail.php for 172.73.244.114
MIME-Version: 1.0
Content-type: text/html; charset: utf8
From: <do-not-reply#aeroblog.tk>
Message-Id: <20151207002526.929B018B5C7#srv10.000webhost.com>
Date: Sun, 6 Dec 2015 19:25:26 -0500 (EST)
<HTML>
<HEAD>
<TITLE>AeroBLOG - Verification Email: Welcome, MikeIsMyName</TITLE>
<META http-equiv='content-type' content='text/html; charset=utf-8' />
<STYLE>
</HEAD>
<BODY>
<IMG src="http://aeroblog.tk/img/VerificationEmail.png" alt="copy & paste this link into your browsers navigation bar: http://........." width="1024px" height="768px">
</BODY>
</HTML>
Some e-mail servers blocks images contents from some e-mails. Did you try looking at the "source code" of the e-mail? In gmail you can find it by clicking in Show Original Message. Another thing that can be happening is that the client is not able to access the image file in your website, or the image link is incorrect.
If you still have trouble with this, I recommend using PHPMailer to send your e-mails. It's really easy to use and has a lot of functions, such as SSL and TLS or Attachments in e-mails.
I am unable to send emails to users through the Mandrill plugin in Laravel using BCC. I can send emails "to" the addresses, as follows:
Mail::send('emails.coach_invite', $data, function($message) use ($coach, $emails) {
foreach ($emails as $email) {
$message->to($email);
}
$message->subject($coach->first_name.' '.$coach->last_name.' has invited you to try Nudge!');
});
This works just fine. However, if I try to BCC the same users:
Mail::send('emails.coach_invite', $data, function($message) use ($coach, $emails) {
foreach ($emails as $email) {
$message->bcc($email);
}
$message->subject($coach->first_name.' '.$coach->last_name.' has invited you to try Nudge!');
});
Nothing happens. Mandrill doesn't even acknowledge that the request came in. Any ideas why this isn't working? If it helps, here are my raw email headers:
Message-ID: <688aa904847640c9ff694521ccb85ee5#nudge-api.app>
Date: Thu, 07 Aug 2014 11:15:35 -0400
Subject: Coach McTest would like to be your Coach on Nudge!
From: Nudge Info <info#nudgeyourself.com>
Bcc: Chris Garson <chris#nudgeyourself.com>
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
I can confirm that sending emails to Bcc users doesn't really work as expected in Mandrill.
The easiest way to send what you want (single email to multiple addresses, with each addressee only seeing their own name in the delivery list), is to set the X-MC-PreserveRecipients header to false and then just send the email using the To field rather than Bcc.
This will send the email as if it were sent to each recipient individually, rather than as a group email - nobody will know who else was sent the email.
Here's how to do it in Laravel using your example:
Mail::send('emails.coach_invite', $data, function($message) use ($coach, $emails) {
foreach ($emails as $email) {
$message->to($email);
}
$message->subject($coach->first_name.' '.$coach->last_name.' has invited you to try Nudge!');
$headers = $message->getHeaders();
$headers->addTextHeader('X-MC-PreserveRecipients', 'false');
});
Note that I'm using $message->to() to address the email and then adding the X-MC-PreserveRecipients header which is set to false.
I worked for me both CC and BCC way.
Ref document: https://mandrill.zendesk.com/hc/en-us/articles/205582117-Using-SMTP-Headers-to-customize-your-messages
Search keyword: X-MC-PreserveRecipients
$headers = $message->getHeaders();
$headers->addTextHeader('X-MC-PreserveRecipients', true);
Using the X-MC-BccAddress should do the job. You can only use one bcc address though.
See https://mandrill.zendesk.com/hc/en-us/articles/205582117-Using-SMTP-Headers-to-customize-your-messages
I'm using PHP to generate a fancy HTML email to send to visitors, but for some reason certain visitors are saying the HTML isn't working for them (seeing RAW HTML rather than pretty email).
I haven't narrowed it down to a certain client, but having talked to them they say they can receive other HTML emails so it's something I'm doing wrong...
My PHP code is as follows
$to = 'jm391#le.ac.uk';
$subject = 'Daily Update - New Bikes Matching Your Alerts';
$headers = "From: john#findthatbike.co.uk\r\n";
$headers .= "Reply-To: john#findthatbike.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (mail($to, $subject, $message, $headers)) {
echo 'Your message has been sent<br/>';
} else {
echo 'There was a problem sending the email.<br/>';
}
And my $message variable is loaded with the below links HTML source
http://www.findthatbike.co.uk/sampleemail.html
My customer forwarded a non working email to me and the forwarded chunk look like the below, I'm told he gets HTML emails from others so really not sure what to try...
From: john#findthatbike.co.uk [mailto:john#findthatbike.co.uk]
Sent: 05 April 2013 08:35
To: XXXXX XXXXX
Subject: Daily Update - New Bikes Matching Your Alerts
Reply-To: john#findthatbike.co.uk
MIME-Version: 1.0
Content-Type: text/html; charset=ISO-8859-1
Message-Id: <20130405073022.8597D9CF79D#MY SERVER ADDRESS>
Date: Fri, 5 Apr 2013 08:30:22 +0100 (BST)
X-invURIBL-Scan: Scanned by invURIBL 3.1.1 on 05/04/2013 08:34:17
X-invURIBL-Weight: 0
X-invURIBL-Range: CLEAN
X-Declude-Sender: MY SERVER NAME [MY SERVER IP]
X-Declude-Spoolname: 72086847.eml
X-Declude-RefID:
X-MessageStream-Note: Scanned by MessageStream (www.messagestream.com).
X-MessageStream-Scan: Score [0] at 08:34:29 on 05 Apr 2013
X-MessageStream-Tests: Whitelisted
X-Country-Chain: UNITED KINGDOM->destination
<html>
<body style="background:url('http://findthatbike.co.uk/images/bg3.jpg') repeat fixed 0 0 #EEEEEE; padding-top: 10px; padding-bottom: 10px;">
I've built a mailer form in php that allows me to just type in an email address and it fires an email directly to the address entered, this is to save a stupid amount of time due to the fact that i've got to send thousands. The php is below:
<?php
{
$to = $_POST['contactEmail'];
$subject = "UK Exporters - Buyers of Commercial Vehicles";
$headers = "Content-type:text/html;charset=iso-8859-1";
$message =
"
<html><head></head><body style='font-family: arial;'>
<span style='font-weight: bold;'>To whom it may concern,</span><br /><br />
At UK Exporters, we are buyers of Scanias, Volvos, Mercedes, Renaults, DAFs.<br />
Runners and non-runners.<br />
4 X 2’s, 8 x 4’s, 6 x 2’s.<br /><br />
We need your old stock for export orders. Top prices paid. For export orders. If you have any items that you believe we would be interested in purchasing then please reply and let me know. Thank you for reading this email, we hope to hear from you soon.<br /><br />
Kind regards,<br /><br />
Sam<br />
UK Exporters<br /><br />
<img src='http://uk-exporters.co.uk/emailer/card.jpg' />
</body>
</html>"
;
mail($to, $subject, $message, $headers);
echo "Another bites the dust! :D<br /><a href='http://uk-exporters.co.uk/emailer'>Send another</a>"?>
<?php }
?>
I'm not a php expert, so any help would be appreciated, i've also list the reasons why it's being marked as spam:
Content analysis details: (5.5 points, 5.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[82.197.130.210 listed in list.dnswl.org]
0.0 HTML_MESSAGE BODY: HTML included in message
1.8 HTML_IMAGE_ONLY_08 BODY: HTML: images with 400-800 bytes of words
1.1 MIME_HTML_ONLY BODY: Message only has text/html MIME parts
1.3 RDNS_NONE Delivered to internal network by a host with no rDNS
2.0 MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required MIME
headers
The email would send perfectly well, until I tried sending an image along with it, any ideas guys?
Your analysis details are clear enough. You need to make your header more suitable to your message, by adding the one below:
#For 'Content-Type' found without required IME headers
$headers .= "MIME-Version: 1.0" . "\r\n";
Also seems you missing FROM Address in header
$headers .= 'From: from#email.com' . "\r\n" .
For more on mail headers do read this.