WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] where to place -f switch in mail() (9 posts)

  1. jkuruppu
    Member
    Posted 7 years ago #

    just upgraded to 2.2; every time i upgrade, i have to add the "-f username@domain.com" into the mail command.

    i located the code for wp_mail in the pluggable.php file, but i can't figure out where to put the -f switch. can anyone help me out? TIA

    here's the code:

    if ( $headers == '' ) {
    		$headers = "MIME-Version: 1.0\n" .
    			"From: " . apply_filters('wp_mail_from', "wordpress@" . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']))) . "\n" .
    			"Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    	}
  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    WordPress 2.2 no longer uses the mail command directly. Instead it uses the PHPMailer class, which handles all that sort of thing for you.

    Anyway, the default usage of PHPMailer actually does add the -f parameter, if a Sender is set.

    So look in the class-phpmailer.php file, and find this:

    /**
         * Sets the Sender email (Return-Path) of the message.  If not empty,
         * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
         * @var string
         */
        var $Sender            = "";

    Change that so that your Sender = "user@domain.com".

  3. jkuruppu
    Member
    Posted 7 years ago #

    Otto42 - you are a star!!!

    that was exactly what i needed to know, and now everything works.

    for those of you who are getting the following message that says:

    The e-mail could not be sent.
    Possible reason: your host may have disabled the mail() function...

    this might be the solution for you.

    i had contacted my ISP awhile ago, and was told that i had to have the -f switch set for their security systems to work and send email through PHP sendmail function. this now seems to be even easier than ever!!

    again, Otto42 - thanks!!

  4. giesbert
    Member
    Posted 6 years ago #

    Thx Otto42! that solved my problem too 8-)

  5. HansMuenchen
    Member
    Posted 6 years ago #

    Hello,

    I try it also but the field from will be allways empty. Doesn't matter if I set it to sendmail, mail or smtp.

    Someone any idea?

    Thnx for the help.

    Greetings out of Munich
    Hans

  6. nplblog
    Member
    Posted 6 years ago #

    What other settings needs to done so an email will be sent to the moderator when somebody posts a comment? Does this work for internal blog too?

    Thanks.

  7. ajmcoelho
    Member
    Posted 6 years ago #

    not working for me....

    I'm using wordpress 2.3.3

  8. andrewscott
    Member
    Posted 6 years ago #

    This ALMOST works for me.

    If i put my email address in the area (as noted above) it does send mail BUT the reply page is blank (wp-comments-post.php)

    How do i fix that?

    Thanks

  9. Dani3l3
    Member
    Posted 6 years ago #

    Why don't just add some little code in the class library that will automatically pick up the default email addess setting (it's there, in the "from:" field, why not use the same one as "return-path:" ?

    The thing is, I have never figured out this happened, until some user started complaining that they did not receive lost password reset information... since their mail provider was dropping the mails as spam :-(

    This is something that can be easily changed (so now I changed it and it fixes the issue), but... one will inevitably loose the change and have to do it again at every upgrade. Which I am not sure I will remember :-(

    Thanks a lot,

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags