3

I am trying to send mail using PHP Mailer but there is an issue with setfrom() method

In $mail->setFrom('[email protected]', 'Jay');

When I use domain name .com mail gets sent and received properly

But when I use . co domain name example $mail->setFrom('[email protected]', 'Jay'); Its doesn't show any error and says mail sent successfully but mail isn't received on my account.Tried changing google privacy settings.

Note:Not using SMPT kept it to false using default settings

Update:Ok so the thing is It is working but the emails are being receive after hours and hours if I use .co but when I use .com email are received immediately. Probably server problem.

2 Answers 2

1

This sounds like a known problem that's been answered before: gmail does not allow setting arbitrary from addresses. You can preconfigure aliases in settings, but you can't simply start using them at the sending client. You can see the submission conversation by setting $mail->SMTPDebug = 2;, but if it's sending successfully, PHPMailer has no involvement beyond that point.

2
  • Well I am not using smtp to send I have kept it to false I am using the default settings.Tried changing gmail setting to show less secure but no luck Apr 14, 2016 at 10:00
  • This also explains it - if gmail is rejecting your message, you may never find out about it. You need to look in your mail server logs. Using SMTP from PHPMailer can make things much more transparent, but there are some downsides to it, mainly that PHPMailer isn't an MTA.
    – Synchro
    Apr 14, 2016 at 10:16
0

Ok so the problem was the server (bluehost)

What was happening is whenever the setFrom() had an email address whose sub domain was not '.com' eg: " [email protected],[email protected]" the mail was being received after several hours.

It would work normally if setfrom() was set to a normal address eg: [email protected] .

Probably a server issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.