SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Norfolk
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    phpmailer and return-path

    How do I set the return path using phpmailer?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,671
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    TriDuo,

    Try using the following (corrected for your use with a phpmailer object named mail):

    PHP Code:
    <?php
        $mail
    ->From "Me@MyDomain.com";
        
    $mail->FromName "Your Name";
        
    $mail->AddReplyTo("Me@MyDomain.com""My Myself & I");
    ?>
    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Norfolk
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Hi DK,

    Thanks but that didn't do the trick.
    If the e-mail goes through, the AddReplyTo allows me to set where I want the reply to go but I'm looking to get responses for the e-mails that bounce.

    When I look at the headers in my e-mail it shows
    Return-Path: <apache@admin.mydomain.com>

    I'd like it to be
    Return-Path: <me@mydomain.com>

    I've also tried extending the class as below but that hasn't worked either
    class MyMailer extends PHPMailer {
    // Set default variables for all new objects
    var $From = "me@mydomain.com";
    var $FromName = "TriDuo";
    var $Sender = "myself@mydomain.com";
    }


    Any other solutions?

  4. #4
    SitePoint Member
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're referring to this: http://phpmailer.sourceforge.net
    then it should be defined with the $sender var, not?

    Quote Originally Posted by phpmailer docs
    string $Sender = "" (line 74)

    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.
    so just edit line 74 of the class.phpmailer.php file.

    Makes sense to me... but no guarantees
    Best Regards
    Colin Frei

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,671
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    TriDuo,

    ColinF has suggested changing the DEFAULT From setting in the class.phpmailer.php file. That would still be overwritten by the assignments ( $mail->From = "TriDuo@mydomain.com"; and $mail->FromName = "TriDuo"; ) to the class variables.

    From the look of your errors, though, it seems as if your SMTP setup in Apache is what's being sent instead (<apache@admin.mydomain.com>). If this is on your own server, you can change this in the Apache configuration. If it's on a shared server, your host will likely not allow this to be changed but should be able to tell you how to get around this.

    I would expected $mail->From to have overridden the Apache's From setting for you so I have to ask if you've tried these statements in your script (before attacking Apache's config file).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    The knight who said ni! RockyShark's Avatar
    Join Date
    Apr 2003
    Location
    Rockhampton, Australia
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having similar trouble. The weird thing is, that everything works except AddReplyTo!

    So, for example:

    PHP Code:
    $mail->From=$Email;
    $mail->FromName=$Name;
    $mail->Subject=$EmailSubject;
    $mail->AddAddress($ToEmailAddress,$ToName); 
    all work fine. But this one:
    PHP Code:
    $mail->AddReplyTo($Email); 
    doesn't seem to override the default nobody@cesiumx.myhost.com. Emails go through okay, but when they do bounce the go back to my host.

    Anyone else had this trouble? Why would one line fail and all the other work okay???

  7. #7
    SitePoint Addict toggg's Avatar
    Join Date
    Jan 2005
    Location
    Auvergne/France
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to know, which phpmailer are you talking about ?
    from xoops, sf, or the similar ?
    edited, inherited ? you really affray me.
    Quick test, quick modified and back and again and forth.

    Could it be the last stage (SMTP) building the end message ?

    You want Return-Path different from ReplyTo or do I miss the subject ?
    bertrand Gugger toggg.com linux, PHP, Auvergne/France open source

  8. #8
    The knight who said ni! RockyShark's Avatar
    Join Date
    Apr 2003
    Location
    Rockhampton, Australia
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm talking about this one: http://phpmailer.sourceforge.net/

    you really affray me.
    Quick test, quick modified and back and again and forth.
    Sorry - I'm not sure what all that means...

    But I haven't edited the class.phpmailer.php file if that's what you're asking.

    I don't necessarily want it to be different, I just want it to be there. If I don't specify anything, it's the standard server address above. If I do specify an address using AddReplyTo() it makes no difference.

    I haven't specified it should use SMTP, and I haven't even uploaded class.smtp.php... So if it were an SMTP issue the mail would probably not even send in the first place. I think.

  9. #9
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is a very old thread!.. sorry to reply to an old thread.. just thought this will be useful to some one else...

    to set the return path in phpmailer you have to use

    PHP Code:
    $mail->Sender="mailer@example.com"

  10. #10
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jaikar View Post
    this is a very old thread!.. sorry to reply to an old thread.. just thought this will be useful to some one else...

    to set the return path in phpmailer you have to use

    PHP Code:
    $mail->Sender="mailer@example.com"
    Ok. But what if I need to the return-path to be diferent from the Reply-to address??


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •