Quote:
1- it doesn't work on localhost.
Check your PHP configuration (
php.ini) regarding the mail setup. Check your Firewall settings.
Quote:
2- on the server where the website is hosted it worked only when sending to GMAIL account but without sending the attachment.
Have you tested other mail servers? If yes, have you changed PHP mail configuration accordingly?
$headers = "From: $senderEmail";
This line may be the reason that the mail is not send on localhost or to other servers. Many SMTP servers will only accept mails where the
From matches their own domain(s).
As already suggested in my answer to your previous post: Have you inspected the raw content (plain text) of the received mail to check if it is in a valid format?
In my previous answer I noted that mails should use CRLF (\r\n) terminated lines but you are still using single LF. While most mail programs accept LF terminated lines, you should not rely on that. With Windows, you should also set
sendmail_from
in
php.ini.
This line contains an invalid content type:
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " // ...
At least the above line and not using CRLF makes your mail not a valid (RFC conform) one. When creating mail content you should ensure that it is valid which requires knowing the format by reading the corresponding RFCs.