I am using PHP's mail() function to send emails (sendmail process is running). But all the mails are going to spam (in case of gmail). I have tried many tricks that I found on the net but none is working, please tell me about any sure-shot trick.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You must to add a needle headers:
Sample code :
There is no sure shot trick. You need to explore the reasons why your mails are classified as spam. SpamAssassin hase a page describing Some Tips for Legitimate Senders to Avoid False Positives. See also Coding Horror: So You'd Like to Send Some Email (Through Code)
This works fine for me.It includes mail with image and a link and works for all sorts of mail ids. The clue is to use all the header perfectly.
If you are testing it from localhost, then set the below before checking:
How to set mail send from localhost xampp:
comment everything in
D:/xampp/sendmail/sendmail.ini
and mention the below under[sendmail]
smtp_server=smtp.gmail.com smtp_port=587 error_logfile=error.log debug_logfile=debug.log auth_username=yourmailid@domain.com auth_password=your-mail-password force_sender=yourmailid@domain.com
In
D:/xampp/php/php.ini
a. Under[mail function]
SMTP = smtp.gmail.com smtp_port = 587
b. set
sendmail_from = yourmailid@domain.com
c. uncomment sendmail_path = "\"D:\xamp\sendmail\sendmail.exe\" -t" Hence it should be look like belowd. comment sendmail_path="D:\xamp\mailtodisk\mailtodisk.exe" Hence it should be look like below
e.
mail.add_x_header=Off
Try PHP Mailer library.
Or Send mail through SMTP filter it before sending it.
Also Try to give all details like
FROM
,return-path
.