We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24629
    • 370 Posts
    Hi
    I'm trying to get Modswiftmailer 0.3.1 to work most of works except the from headers.
     $visitorsmail->address('to', '[email protected]', 'visitorsname');
        $visitorsmail->address('sender', '[email protected]');
        $visitorsmail->address('from', '[email protected]', 'Organisation name');

    the thing that happens here is that the TO adress gets used in the from field when i receive the mail
    the header says
    From: visitorsname <[email protected]>, Organisation name <[email protected]>

    this is obviously not correct. Anyone know how to fix this?
    Tnx
    Rdg
    [ed. note: rdaneeel last edited this post 13 years, 1 month ago.]
      • 24629
      • 370 Posts
      I found out that using
      $modx->mail->receipt('[email protected]');
      is responsible for putting the extra address in the From statement. just in case anyone else stumbles upon this one day.

      RDG
        • 24629
        • 370 Posts
        After testing some more i found out that there is a strange phenomena.
        Whe i send two mails after each other the FROM adress is not set properly in the second mail.
        so
         $firstmail = $modx->getService('mail', 'mail.modSwiftMailer');
         $firstmail->address('from', '[email protected]', 'Me');
         $firstmail->address('sender','[email protected]', 'Me');
         $firstmail->address('to', '[email protected]', 'You');
         $firstmail->subject(subject1);
         $body ='hello there';
         $firstmail->body($body, 'text/plain');
         $firstmail->send();
        
        // now sent the second mail
        
         $secondmail = $modx->getService('mail', 'mail.modSwiftMailer');
         $secondmail->address('from', '[email protected]', 'Me');
         $secondmail->address('sender','[email protected]', 'Me');
         $secondmail->address('to', '[email protected]', 'You');
         $secondmail->subject(subject1);
         $body ='hello there';
         $secondmail->body($body, 'text/plain');
         $secondmail->send();


        Now you'll see both mails in your mailbox and BOTH mails af the from address of the first mail.
        the second mail should have [email protected] in the from field.Instead it has the FROMaddress of the firstmail