I am not sure if this belongs here or at serverfault but the thing is, I have a zencart installation which sends mails using phpMailer( using 'PHP' mode,that is the php's mail() function). Now when these mails fail they bounce to a particular mail address, whereas I need to make sure that the bounced mail always goes to the "From" address which sent it. I think this is beyond the scope of phpMailer, but is there any way for me to achieve this properly? I really don't wanna run a cron job, check the bounce email inbox and then send the mails where intended. Is there any other way?
Oh and if this is any help, I have access to cPanel, and WHM for the server, so if there is any settings that I need to modify, please let me know.
The most effective way to get your email delivered correctly is to use SMTPAUTH and provide credentials for a valid SMTP mailbox. That way the "from" address and bounce address will be handled by the SMTP server.
Related
I'm created a website with PHP on a Linux web hosting package. Normally I will get emails sent by its contact form that produced by PHP Mail() function. But this time, it is a strange case for me.
My customer company has a mail server. If I send an email via my personal email on Gmail, they will get it on their mail server. But when I send emails via contact form, emails go to webmail on website hosting package.
I've removed all email accounts on this host, also I removed DNS MX record from it, but still I can not receive emails sent by contact form on the company mail server accounts.
How can I solve this problem?
As it seems from your question the webshoting provider is also your email hosting provider. The way you explained the problem leads me to the conclusion that your PHP script uses the mail() function which will internally call the MTA (like sendmail) to send the email.
Now what seems to happen here is that PHP is sending the mail through mail() function which is passing it on to the local MTA (like sendmail) which is checking the local configuration. In the local config it seems to find the recipient domain as a local domain and deliver the mail locally to the user. In this case the email is not even leaving the webhoster's server.
As this is not what you expect, you have 2 possibilities if you do not have influence to the MTA's configuration (what i think you dont have).
I would propose (if possible) to not use the mail() function. There are ready to use SMTP classes which will connect to a SMTP server of your coice to send the email to. In that way you can avoid this problem. You should find something in the PHP Classes Repository.
Send the email to a different domain if possible. That way the MTA has to check DNS and send the email to another SMTP server for delivery.
The first thing to establish is how you are sending emails (sendmail or SMTP). Then, whether your emails are a) not sent at all or b) getting rejected by the destination mail server.
I'd check all available logs (source and destination mail servers and daemons). See if mail() itself is erroring. Try using sendmail/smtp directly.
If its the destination server rejecting the mail based on its spam score, try setting SPF records to enable the web server to send mail legally.
If your email function "mail($to,$subject,$message)" is not working then you need to check the server configuration. Now it is enable or not .
For more details, see here : https://wycks.wordpress.com/2013/10/09/when-phps-mail-function-doesnt-work/
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.
I'm using PHP mailer to as part of an enquiry form that I'm building for a client. One thing I've noticed in testing is that when I use my yahoo account as the FROM and my gmail as the to it works fine for a while but then it starts rejecting, I'm assuming because gmail is smart enough to know that the email isn't actually coming from Yahoo.
What is the best solution to this? I could use the email from the person who has actually filled in the form to show as the FROM address but I'm worried that this may eventually cause the same problem anyway? I could also send it from an email on the domain that its sending from but will that stop it from appearing as spam or black listing that email?
Any help or guidance would be great?
You are getting tagged as a spammer because you are sending the same message over and over. Set up your own mail server without a spam filter while developing if this is a problem.
You are not Yahoo -- don't pretend to be them! Set the From field to an address at the domain that's sending the mail (e.g, if your domain was example.com, send from something like inquiries#example.com or noreply#example.com).
This is probably related to SPF records. mail() will most likely try and send the mail directly to the server(s) identified by the MX record of the recipient domain, and because you are not sending from an IP address that is recognised as one of Yahoo's, Google will reject the email. If you are on *nix, you may be able to configure your system's sendmail program to relay via Yahoo. This is not an option on Windows (I don't think) because Windows has no sendmail and PHP will send the mail itself.
If you want a cross-platform solution you can use something like PEAR::Mail to relay the message through Yahoo's SMTP servers - this should resolve the problem as long as the SPF record is the source of the problem.
If your email is getting flagged as spam because of the content of the message, the only solution is to change the content of the message.
We have a client that can't receive emails from a dedicated server using PHP mail because when their SPAM server does an MX record lookup for the IP it can't find one (so it bounces the email).
This is because the mail exchange is on a different server completely. The client said that they have an IP address that bypasses the SPAM blocker.
So I'm wondering if PHP mail can send an email to a specific IP?
Does your server not qualify as a mail sender by their spam filter? Because I'm guessing that they can receive mail from other people.
So I think you need to look at the setup of your server so it complies with their qualifications (like a reversible name for example, or whatever other rules they require from an email sender)
Because with PHP (and other languages) you just send the email, there are tools that send an email through another server that is qualified to send emails, but usually you use the server itself.
For example, you can use the Zend Mail library to send through another SMTP server.
The answer is yes. However, how the mail() call in PHP actually sends the mail is totally dependent on how your system is set up, so any problems you're having sending mail won't be resolved in your PHP code, they'll be in your mail set up.
Generally, you should be able to address a piece of email to "user#192.168.1.1" and have it arrive successfully.
There's a good article about some of your mailer settings here.