I am building a website with PHP for a client. The website has a contact form, so I added the phpmailer class to be able to send the contact form details to the client's mail address.
Now, when I configure the phpmailer class, I have to provide the SMTP server username and password (I used smtp.gmail.com). I highly doubt that my client will give me his gmail credentials.
When I use the phpmailer class without enabling SMTP configuration (i.e not giving $mail->isSMTP() and the relevant configurations that follows it), I get the message marked as SPAM in my inbox. I can't use the php mail function because I want to format the body of the email as a template with HTML and CSS.
Is there a way I can use the phpmailer class(no SMTP) without getting the email marked as SPAM? or Is there any other solution for the problem I am facing?
Emails sent by phpmailer being marked as SPAM is a much more complex issue. You might find a good explanation:
phpMailer gmail spam
Even the GitHub of PHP Mailer also has this discussion:
https://github.com/PHPMailer/PHPMailer/issues/111
There are also quite a few search results on Google, regarding this topic.
Related
My friend has got a e-commerce website where users can choose to receive mail with the new offers. So he asked to me to create a system to send them an email.
How can I with php send an email to all the people in the mailing list?
I know that editing the php.ini I can send mail from my personal email, like GMAIL, but it has a maximum number of mails for day.
So what is the right way?
The right way to do this is with SMTP.
http://www.jvfconsulting.com/blog/php-mail-function-vs-smtp-guaranteed-delivery/ explains that the standard php mail function sends mail, but your mails can be heavily blocked by anti-spam mechanisms of ISPs.
There are many prebuilt solutions, PHPMailer being one of them. Please see this link as well: send email using Gmail SMTP server through PHP Mailer
None of my Wordpress emails are sent to Gmail. More info:
I am using EXIM mail server
I am using wordpress latest version
it happens only when emails are sent to Gmail
EXIM logs say that the email is sent succesfully to Gmail, but they are not sent, or sent in spam.
The problem is a combination of factors:
EXIM, unlike postfix, is not automatically setting the Sender header
Gmail recently made some changes to deal with spam better, and if the email headers are missing the Sender header, it will most likely silently discard it, or send it as spam.
Wordpress doesn't set the Sender header
Once you know these, the fix is quite simple. If you are using Wordpress, the quick and dirty way to do it is to go to wp-includes/pluggable.php, look for the wp_mail() function search for:
$phpmailer->From = apply_filters( 'wp_mail_from' , $from_email );
then add the following right after it:
$phpmailer->Sender = $phpmailer->From;
Once you do this, emails will work, and you can fix the problem the proper way, without overwriting the core, by writing a plugin. Wordpress uses phpmailer which knows about this issue, but wordpress doesn't use it. There is also a bug report on this issue.
To fix the problem using the core mail() function, you have to do the following:
// $sender can be the same email address as the From header
mail($to, $subject, $message, $additional_headers, "-f {$sender}")
There is another option that may work, depending on the configuration of your server (I couldn't test it, would love if someone could test this):
$sendmailFrom = ini_get('sendmail_path');
ini_set('sendmail_path', $sendmailFrom . ' -f sender#mysite.com'); // or whatever you want
Gmail (and likely Hotmail and Yahoo eventually) is starting to disable traditional SMTP authentication mechanisms (PLAIN, LOGIN and CRAMMD5) in favour of OAUTH2.
If you send mail with WordPress (PHPMailer) alone, Gmail will discard it or mark it as SPAM. If you send mail with a typical WordPress SMTP plugin, Gmail will give you an authentication error, or make you jump through hoops like application-specific passwords, two-factor authentication, and enabling less secure apps as an account setting.
The first plugin to implement OAuth 2.0 for WordPress (disclaimer, I am the author) is Postman SMTP. If port TCP 465 allows outbound connections to Gmail, your WordPress emails will be delivered by Postman without error.
I have an app where i'm sending emails on certain events, but when i used my gmail account, i never receive the emails and they are not in my spam folder. When i send them to my work email, i receive them instantaneously.
What do i need to do to get the emails through to google?
I'm using the standard codeigniter email configs (which i think uses sendmail).
I'm using google apps for business and i have the MX records setup that google provides.
Do i need anything else? Also, i'm using subdomains in my app, does that affect what i may need to setup?
EDIT
When i use smtp like this example Sending email with gmail smtp with codeigniter email library, the page never seems to come back. It eventually just timesout.
The only plausible explanation for this behaviour is a SPF Check failure. SPF or Sender Policy Framework is a new technology that allows easy detection of spam. Gmail honours SPF unless you manually mark those emails as not spam. Regardless of this, if you have received emails on another address then they must have reached Gmail too. Check your spam thoroughly, as Gmail does not discard emails even on very high spam suspicion rather they end up in the Spam folder.
You can set up a SPF that allows your webserver to send emails which will result in Gmail accepting emails sent by your webserver as authentic. See http://www.mydigitallife.info/how-to-set-up-and-create-sender-policy-framework-spf-domain-dns-txt-record-with-wizard/ and a wizard from Microsoft.
You will probably see, that at some point in the future, you'll get them all appearing in Gmail. Google is most likely seeing if the sender is spam, and holding those messages. I've experienced that before setting up dev servers. I would suggest using a transactional email service, like Mandrill or SendGrid. You'll find you get a lot of info from those services that you forgo if you simply send an email through PHP.
The Filter Theory The other possibility is that the poster has a filter set up on their GMail account that is filtering out the emails.
I would make sure that you are sending the required header information as well. Have you tried registering a new gmail account and sending it to that user?
I have a webpage that sends out emails using phpmailer. I set the host to 'relay-hosting.secureserver.net' the mail->sender, mail->from and mail->addReplyTo all to the same address, which is the address that I want the bounced email notifications sent to. This email address in also with the same host and the smtp host. When I put in a bad email address I don't get a notification that is was not delivered. What am I doing wrong? Thanks
PHPmailer does not handle receiving emails. It's purely a library for allowing PHP to talk to an SMTP server for sending emails. It has absolutely no support whatsoever to act as a mail client (e.g. receiving).
PHPmailer has no way of knowing the email bounced, as the bounce occurs LONG after PHPmailer's handed the email off to the outgoing SMTP server. IN real world terms, PHPmailer takes your letter and walks down the block to drop it into a mailbox. The bounce occurs later, when the letter carrier brings the letter back with 'return to sender' stamped on it - PHPmailer is not involved in this at all.
Your options are:
1) Use PHP's imap functions to connect to an existing pop/imap server and retrieve emails that way
2) Use a .forward or similar redirect on the SMTP side to "send" incoming email to a PHP script.
I know this is an old and answered question, but for those who may find this post later with a similar problem you might be able to solve this by going to your smtp mail relay service. If for example you use jangosmtp there is an option in your jangosmtp control panel to either hard code the address to which bounce reports should be sent or to always send bounce reports to the From address.
I'm using PHPMailer for sending activation codes to users. As far as I know, that's best script for this purpose. Today noticed that, some users doesn't receive activation codes. But mailer return "Succesfully sent" message. Is there any chance that, phpmailer can't send to some mail servers? Or which is the best php script for sending mail via smtp authentification in your opinion?
It's not obvious that it is PHPMailer problem. It has connected to your smtp server and successfully sent the message. By successfully I mean that your server has accepted it. What happens next is a mystery and you have no control over it.
Few common reasons of undelivered mail:
marked as SPAM by foreign server (advise users to check their spam folder)
target mailbox does not exist (typos in username etc)
user inbox is full and will not accept new mail
mail queue on the server is quite big and it will take few minutes / hours to deliver
The best you can do is to advise users to keep their mailboxes clean, check their spam folder, retype email to prevent typos and offer a service for re-sending the activation email.
I send registration and activation emails using SwiftMailer via Google Apps Mail (support#mydomain.com). It works like a charm, easy to setup, and has no delivery issues since it's using Google's servers. Check it out.