php search imap emails in reply to header - php

I have to search all email sent and from a specific email address with php.
In some emails the email are from different sites and the address is in the reply-to header.
In the sent folder is simple, I'm using the imap_search funcion:
$imapResult= imap_search($imapStream,'TO info#email.com');
Retrieve the message from a specific email address is also simple:
$imapResult= imap_search($imapStream,'FROM info#email.com');
The problem is to retrieve the message from an address via other webservices, having from header the email of another site, and the email of the client in the reply-to header.
A solution is parse the header of all emails in inbox but it will be too slowly.
What is the faster method to search the inbox email with php to retrieve the messages from a email in reply-to header?

I solved the problem using the text option
$imapResult= imap_search($imapStream,'TEXT "info#email.com"');
Now I find in the inbox all the emails from the client.
It's impossible another client send me an email with inside the text the email address of onother people....

Related

How to specify custom sender?

I'm using the $email->setFrom('no-reply#example.com'); method and it's working fine for email delivered to the registered sender.
However, the email is delivered as no-reply#example.com.
How can I include the email of the customer that has filled the form? Eh: mario#gmail.com?
If I replace $email->setFrom('mario#gmail.com'); I will get 403.
This happen because I have to register the sender. But I just need to create a simple contact form.
Is there a way to use setFrom using a custom email?
Thanks in advance
Twilio SendGrid developer evangelist here.
When sending emails with SendGrid you do need to verify the email or domain you are sending from. So, you can't use any email address as the from email.
You're creating a contact form, which is why you want the email to appear to come from the person sending it. However, what you really want from that is to be able to reply straight to the person that sent the email.
What you can do is send the email from a domain or email address you have verified and then set the reply-to header to the user's email address. You will receive the email from your chosen email address but when you go to reply the to address will be filled in with the custom email address.
$email->setReplyTo("mario#gmail.com");

PHP mail() - Different domain emails for From and reply-to

I want users on my website to use php mail() to send emails from my website domain. I would like users to get replies on their personal email address which will not be my domain email it might be gmail, hotmail or any other. When I do so, the email recipients get a phishing warning in gmail.
How can I set headers in php mail() so different sender and reply-to emails do not make gmail and other services tag the email as spam or phishing.
Your recipients are getting a pishing warning because your emails are not passing SPF checks. That simply means that the from domain you are using is not authorizing your server to send mail on its behalf.
Try using PHPmailer https://github.com/PHPMailer/PHPMailer
You can use it to set a separate from address as well as a specific reply to address
$mail->AddReplyTo('replyto#email.com', 'Reply to name');
$mail->SetFrom('mailbox#email.com', 'Mailbox name');
That being said. The SetFrom address is an address that must pass SPF and preferably DKIM checks to be NOT marked as SPAM or PISHED. This address is recognized as the BOUNCE address where all the bounced emails will be returned to. Not having a valid address may possibly disrupt future deliveries.
The AddReplyTo address will be loaded when the reply button is clicked by the recipient. Keep in mind that even though the message may pass SPF there are many SPAM filters that will potentially mark the message as spam.
The easiest way to get this working is to create an email address on your website (me#mysite.com) then get the website to automatically forward all mail to your gmail account. Then, use the website email address in the 'From' and 'Reply-To' address of your mail() routine.

PHP mail() headers not working with certain "from" email adresses

Didn't find the exact answer for my question. The problem is, the code sends an email (user to user), so I did a $headers for a reply-to with the email entered by the user. In this $headers, I put the "From" email as the email of our website. However, the email does not get sent. It does send appropriately when I put a Gmail or Hotmail in the "from" position. So the problem appears to be our website email. Should I talk to my host or could there be something else? Just ask if there needs to be more details.
Yes, you have to talk with your host for your website email address is working or not.
Please check mail in spam when send using you website email address

Codeigniter PHP Mailer, Sender Info

I'm using Codeigniter PHP Mailer which is hosted here: https://github.com/ivantcholakov/codeigniter-phpmailer/ and with gmail smtp it works flawless.
However,using it for a standard contact form, when visitors use that contact form and send us an email, they basically send mails from our mail address to our another mail addess. When they open their own email address, they wont be seeing what they sent in their own sent items. What I want to do is (maybe without using smtp settings) show the visitors own mail adress (the one I'm asking as an input on contact form) as the FROM part of the email I receive from my contact form. So that, in case I want to reply the mail, hitting the reply button would be enough. İnstead of doing coding tricks and showing their email somewhere I could copy/paste and send new email.
Don't do that. It's effectively forging the from address and will fail SPF checks. Instead, use your own address as the From address, and add the submitted address as a reply-to address. In PHPMailer:
$mail->From = 'youraddress#example.com';
$mail->addReplyTo($POST['emailfrom']);

Sending E-Mail from contact form with the visitors sender address

I've built a contact form in which a sites visitor enters a message, subject and his own email address. The email then is sent to a fixed gmail address.
I'd like the receiver of the mail to be able to just click on answering in order to respond. Therefore I set the senders email to that one entered by the sites visitor.
Problem is, gmail considers those mails as spam. I guess because the DNS of the senders address does not fit to the servers IP.
So I wonder if there is a strategy to achieve what I have described.
There are other email addresses you can add that will probably fix your problem. I suggest that you give your email From, Sender and Reply-To addresses:
From: visitor's email
Sender: your email
Reply-To: visitor's email
Reply-To is the address any reply will go to. Sender means that the email coming from you makes sense. From indicates that you are sending it on behalf of the visitor.

Categories