I am trying to send email with mail() it works but even if I set From: email <name> it is sent with the original email of my server.
Is there anyway to solve this? I have debian with postfix
Use -f mail#mail.com to the last param of mail() and it will work.
Related
I using php and CodeIgniter to send email but after change the server have following strange problem.
Each mail are sent to recipient and to sender.
After long debug of this problem I came to the following case.
mail("example#exmaple.com",$title,$body,$headers);
Work as expect send email only to "example#exmaple.com".
But
mail("example#exmaple.com",$title,$body,$headers, "-f example#domain.com ");
Send email and on both mail "example#exmaple.com" and "example#domain.com"
The problem is I do not know why she sends both emails.
I want to send only to "example#exmaple.com"
Here's what it says about this parameter php.net
The additional_parameters parameter can be used to pass additional flags as command line options to the program configured to be used when sending mail, as defined by the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.
Obviously this parameter needs me but it is only for authentication and should not be sent to the e-mail "example#domain.com",
Mails are sending from my php application using mail function. But client says it is from Mandril mail service. I logged into the Mandril account and found the mails sent. I checked the code. But didn't see any piece of code using the Mandril mail. It only uses php mail function. How can verify this?
My send mail path is configured like:
sendmail_path is /usr/sbin/sendmail -t -i -fadmin#abc.com -Fno-reply.
Note: I don't have access to the server.
The Mandril mail account was configured in sendmail confuguration. So when ever we use the php mail() function it will send through this account. Since the configuration lies in the send mail config file no any piece of code was there in the php code.
While troubleshooting a contact form with an e-mail host they told me to use '-f' in the from address of the php mail function. What does the "-f" flag do and why would that be a fix for allowing an e-mail to be delivered? I read some of the documentation but I'm not quite clear on it.
Example code:
mail($emailAddress, $mailSubject, $mailBody, $headers, '-f ' . $mailFrom);
PS: without the "-f" it works just fine for the big e-mail hosts (hotmail, gmail, etc, but for whatever reason not for the smaller host I'm working with)
Thanks
-f is a parameter to the mailer (usually sendmail). From the docs:
The additional_parameters parameter can be used to pass additional
flags as command line options to the program configured to be used
when sending mail, as defined by the sendmail_path configuration
setting. For example, this can be used to set the envelope sender
address when using sendmail with the -f sendmail option.
Here is the man page for sendmail, you can see what the -f option does:
-fname Sets the name of the ``from'' person (i.e., the sender of the
mail). -f can only be used by ``trusted'' users (normally
root, daemon, and network) or if the person you are trying to
become is the same as the person you are.
The -f option is to set the bounce mail address. Sending a message without one can negatively influence the spam-score that is being calculated over the message. Messages with low scores sometimes get filtered out for certain hosts.
You can use https://www.mail-tester.com/ to test the score of your message. You can expirement with or without the -f flag and see the score change.
It is a flag to mark the following text ($mailFrom) to be used as "from" address of the mail.
Have a look at: http://www.php.net/manual/en/function.mail.php
I use the php::mail() function in my scripts to send out emails from the server. While I can change the From header, the sender still shows as a default address from the hosting server (something#server.thehost.com)
Where in the cpanel settings can I change this address?
Thanks.
Try using the fifth mail() argument: '-f your#sender.address'
A few days ago, i can send email via mail() function on my server. But now, mails doens't sending . There isn't anything at error log. I don't get any error. I don't know, why emails not sending.
What can i do? How can i solve this?
EDIT
Now i get all emails (about 18 mails :) ) . Why mails delayed?
PHP's mailer function does not actually deliver the mail. It simply hands it off to an SMTP server for that. Whether or not it actually gets delivered is not considered by mail(), it's just concerned with the hand-off.
If the SMTP server accepts it, then mail() will return true and pretend everything worked fine. The SMTP server may delete the mail, send it to the wrong place, route it through a tangle of other SMTP servers causing the mail to be delayed by a year, etc..., but mail() will still have said everything's fine.
The place to look for the cause of this is your mail server's own log. If there was a delivery problem, there'd be a list of each delivery attempt in there somewhere.
Have you tried doing this?
The problem seems to be that PHP use
the ini directive sendmail_from to set
the from email address in the SMTP
protocol. If this is not correctly
set, or if it does not match the from
header in the email headers, the email
is caught by spam protection software.
The simplest solution is to set the
directive during execution:
ini_set("sendmail_from", $email_from);
$headers = "From: $email_from";
mail($to, $subject, $message,
$headers);
Ok, now i have got 18 mails together. I don't know, why mails are delaying.
Maybe your receiving mailserver implemented greylisting (http://en.wikipedia.org/wiki/Greylisting) ...
Do you have access to the mailqueue or maillog of your webserver? In that case you can search for delayed or bounced messages there.