My goal is to anwer to a mail to a email that is in a inbox of a mailbox.
I am at the point that I can read the mail out of the mailbox and I can send emails.
The only thing is that I would like it for the receiver of the email that all the conversations are wrapped in 1 email. You know with gmail you see for example a subject like this:
(5) Test subject
This means that this mails contains 5 submails.
But at this point everytime I send a answer to the existing email with php it comes in as a completely new mail. And it does not stack on top of eachother.
Does anyone know how to make these emails stack on eachother.
My current code for sending the mail:
// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers .= "Reply-To: reply#reply.nl \r\n";
// Additional headers
$headers .= "From: sender#sender.nl\r\n";
mail("test#test.nl", "test subject", "test message", $headers);
You have to include the In-Reply-To and the References Header.
In In-Reply-To is the Message-ID-Header you are directly refering too and References are commaseperated values of all messages (e.g. when you reply back and forth, then it would make sense to include all of the message IDs)
Example:
In-Reply-To: <GDKDHK#web.de>
References: <a1gjkr#googlemail.com>,<GDKDHK#web.de>
You need to RE: subject so that they can stack in the email viewer.
Related
I wrote a PHP script to send emails.
My script is like this:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: abc#yahoo.com' . "\r\n";
// Email Variables
$toUser = "someone#yahoo.com"; // recipient
$subject = "testing"; // subject
$body = "<html><body><p>
Example of including an image via html \<img\> tag:
<br>
<img src='../images/profile.jpg'>
<br>
My new picture
<br></p></body></html>"; // content
if (mail($toUser,$subject,$body,$headers)) {
echo "sent";
} else {
echo "failed";
}
Well, of course I use a valid email address for sender and receiver. I did receive the email, but it goes to junk mail. So I went for google research. Is it because of my "header" script problem? If it isn't, then what could cause my script to send a junk mail? Any solution?
Please try this:
$headers ="From:<$from>\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-type: text/html; charset=iso 8859-1";
mail($to,$subject,$body,$headers,"-f$from");
Perhaps the problem is that yahoo uses domainkeys verification, which will likely fail for your application given that the mail is not actually coming from yahoo's servers.
When I've once had a similar problem I looked at the headers and found out that my host uses SpamAssassin. So I googled for 'SpamAssassin score' and found a multitude of information on how to incorrectly (and thus correctly) form an email.
For example: SpamAssassin score list
1. Check mail content
As others have hinted it is probably marked as spam because your mail looks like spam.
I am not sure if you the script that you have posted is the actual one that you are testing.
If it has the actual mail body & headers, then running this message through a standard installation of SpamAssassin gives it a spam score of 4.9
X-Spam-Status: No, score=4.9 required=5.0 tests=BAYES_50,HTML_IMAGE_ONLY_04,
HTML_MESSAGE,MIME_HTML_ONLY,NO_DNS_FOR_FROM,NO_RELAYS autolearn=no
version=3.2.5
Since the email body has only HTML it has a greater chance of being handled with suspect by most anti-spam solutions.
2. Mail server's IP
Another aspect worth checking will be the IP address of your mail server. Any mail originating from dynamic IP addresses will potentially be considered as SPAM.
3. Blocklists
Also check if your IP address is listed in one of the block lists. To start with please check your IP address with http://www.spamhaus.org/lookup.lasso.
Use mxtoolbox.com to check the servers IP to be blacklisted or not. As well this website can help you with a couple of email related checks.
Of course there are a long list of checks running inside spam filters. As already suggested, check the email headers for details about the spam filters rating of the spam email.
Hope that helps!
**This Works Perfectly fine for me**
$to="reciever#reciever.com";
$subject="This is Your Message";
$from = 'Sender <noreply#sender.com>';
$body='Hi '.$name.', <br/><br>Now You can See Yor main in inbox';
$headers = "From: " .($from) . "\r\n";
$headers .= "Reply-To: ".($from) . "\r\n";
$headers .= "Return-Path: ".($from) . "\r\n";;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
mail($to,$subject,$body,$headers);
I was having the same problem:
The problem is that when you specify content-type before the "From:" part , the mail comes as a spam.
But if you specify "From:" before the content part it comes as a normal mail and makes you smile and curious.
As schnalle said, one problem surely is that the smtp server that you use to send the email and the one thet you specify as From, is different.. the from's domain whould be the same that the server youre running on.
So, you can use the yahoo server to send the email (check if they allow the smtp remote connection, but i guess they do) connecting by smtp, and this will solve 1 problem.
Another one is the html contents without the alternative plain text contents, but, this one is less important.
I suggest you phpMailer, free and open-source php class to send email, easly to use (i use it event o send mail through gmail server)
On your server try to sort your SPF (Sender Policy Framework, Google for SPF record) record out.
Make sure you send your e-mails from an existing account on your server/domain.
Make sure you have the reply-to address in your header.
These are the basic things you can try.
if your website domain is mydomain.com then in From headers make sure to use someone#mydomain.com
Remove the Content-type: text/html and add $headers .= "X-Priority: 2\nX-MSmail-Priority: high"; to get rid of Spam. This method has been tried and tested.
the problem is, the server you're sending the mail from is not a yahoo server. most spam filters check if they match, otherwise it would (and is - or was) possible to easily fake the sender. ever wondered why you get spam from bill.gates AT microsoft.com or your own mail address?
You've got two solutions:
use Yahoo's SMTP using abc#yahoo.com credentials to send mail from abc#yahoo.com;
use other from, with your own domain;
You can try the mail class and test file that I have created here. I have tested the files and can send emails to my hotmail and gmail under a different mail name. The main reason why the emails are mark as junk is because the structure (both header and message) is not correctly done. In most cases, it is the line feed that is causing the problem.
I can use it to send mail with attachments to Gmail. However, the attachments dont work for hotmail. Hope this helps =)
You can check the files here..
I write a script to send email from my website. I recieve email in inbox in gmail, outlook and hotmail but in yahoo, its going to SPAM folder and also URL in not working in yahoo. Whats wrong in my code,
Header
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers .= "From: $Name <$Email> \r\n";
$headers .= "Reply-To: $Email\r\n";
Message with URL
$message.= "<a href='https://www.google.com'>Click here</a>";
PHP-Mail function is not uses a well configured SMTP Server so may be this is a reason or try to Use the PHPMailer-Class. or you need to try with full headers
Also links not working cause your mail in spam. need to move in inbox and see.
http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/
For more info follow:- sending email via php mail function goes to spam
This question already has answers here:
Prevent sent emails treated as junk mails using php mail function
(14 answers)
Closed 9 years ago.
I used this tutorial for sending mail :
http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/
My code looks like this :
$headers .= "Reply-To: The Sender <sender#sender.com>\r\n";
$headers .= "Return-Path: The Sender <sender#sender.com>\r\n";
$headers .= "From: The Sender <senter#sender.com>\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("recipient#recipient.com", "Message", "A simple message.", $headers);
I am using localhost(MAMP PRO) for sending mail.
But mail goes to spam folder.How to send mail which goes to inbox.Please guys help me out from this,i spend a lot of time on it.
Which folder an email goes into depends mostly on the domain & ipaddress from which the email is coming from and the email service provider. If your domain/ip is trusted by the service provider it will not be spammed.
Also, after setting a few emails as "Not Spam" from that domain, your email service will no longer spam the emails
there are more than one reason ur email goes to spam ...
1 - make sure that the "from email" is actually the email u are sending the emails from .. i mean dont use any other false "from Email"
2- you have to keep the message body simple as possible . dont use so much html tags and css experssions , and also try to use tables
I have used used the PHP Language for Sending the email and HTML tags are not rendering in the gmail account sometimes.I have used Content Type as - charset="iso-8859-1" I have attached the image.
And also am receiving the Message ID, which should not be come in the mail.
I don't recommend/use php built in mail() function to send and receive emails. Use php open source libraries like PHPMailer and SwiftMailer. I have been using PHPMailer after facing many issues when using mail() alone. Very easy to implement and has lots of features. You don't have to spend your valuable time for email sending related development.
http://phpmailer.worxware.com/
http://swiftmailer.org/
If the HTML isn't rendering, that usually means the headers weren't set properly.
Try this:
<?php
//change this to your email.
$to = "m#m.com";
$from = "m#m.com";
$subject = "This is HTML email";
$message = "
<b>htmlemail....</b> <br>
<a href='http://www.google.com'>Google</a>";
// To send the HTML mail we need to set the Content-type header.
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
mail($to, $subject, $message, $headers);
echo "Message sent..";
?>
From http://www.webhostingtalk.com/showthread.php?t=416467
If I send an email through GMail to this address nkhkhlkhlkjlkjkljlkjlk#gmail.com
I got error like:
Delivery to the following recipient failed permanently
My question is, if I send using the PHP mail function, how can I catch bounce emails?
My code:
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
$to = "nkhkhlkhlkjlkjkljlkjlk#gmail.com";
$subject = "Testing";
$message = "Testing body";
mail($to, $subject, $message, $headers);
You can't detect such errors just by using mail(). You have to specify a valid return address and then connect to that mailbox (via IMAP or POP, there are functions for that) and check if any message bounced. Bear in mind that bounces may take a long time (even hours, due to transient errors) so you have to do this check asynchronously.
you could get the message by mail when you use this:
$bounce = 'test#domian.com';
mail($to, $subject, $message, $headers,"-f $bounce");
This will send all bounce back mails to your address
You could use PEAR MAil, it contains a parseAddressList() method which checks if the server of an email address accepts the email address. It also returns useful error messages.
The PHP mail() function does have an error status as the function return value, but it won't pick up this kind of error because it only checks that the email has been sent, not that it has been received.
(this is because it needs to return control back to the program immediately; it can't wait for a possible bounce message because they can take a long time to come back - you wouldn't want your program to sit and wait for five days just in case the email bounced, would you?)
Therefore, the only way to determine whether a message has bounced is to have a separate program which checks the mailbox which the bounces would be sent to.
You can specify the mailbox for bounces using the -f option in the mail options string (see the PHP mail() function man page for more info on this).
Then have a separate program periodically check that mailbox for bounce messages, and report them to you as required. (there are a number of PHP libraries that allow you to check a mailbox; Google will help here, or look in PEAR)
Determining which email it was will depend on the quality of the bounce message. You should definitely be able to see the intended recipient's email address, but you may not be able to tell which email it was, ie to match it up to a specific instance of when you called the mail() function in the first place.
Hope that helps.
You should login via IMAP or POP3 to your inbox and parse the email address and delivery error.
It's also worth mentioning that you can specify (while sending) custom headers to better track the message source, I believe MailChimp and others do this do track campaigns, etc...
PHP does not know anything about the mail after it got out of the mail function, so no way to do it at the same time as you send the mail.