[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Changing outgoing account

Changing outgoing account

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Changing outgoing account

Postby soniajane » Fri Feb 01, 2008 9:42 am

Hello :)

I'm dipping my toes in uncharted territory here, but I want to be able to change the From/Reply-To and X-Account attributes for some outgoing emails. Basically, if I mail (or reply) to anyone on employer's domain, I want to make sure that my email is sent from that domain too. I have an account set up but it's a pain to remember to change the account manually on each mail when I create it, otherwise it goes from my personal address. At the moment my failure rate is probably about 20%. :(

So - I've set an outgoing mail filter to pick up the cases (where recipients include that domain) and to run the little script that I wrote as follows:

Code: Select all
{ Quit if something goes wrong
Set $OnErrorGoTo Quit

Set $fm "me <me@myworkdomain.com>"

DeleteHeader "From:" %m
AddHeader %m "From:" $fm
DeleteHeader "Reply-To:" %m
AddHeader %m "Reply-To:" $fm
DeleteHeader "X-Account:" %m
AddHeader %m "X-Account:" "Domain account"

Set $a "Something ran!"
AppendBody $a " "
AppendBody $a "Bye!"
Beep
MessageBox $a

:Quit
Exit


Now, I'm getting the messagebox coming up when I send test mails so I know it's running - but when I check the headers of my sent emails, nothing has changed.

I can't figure out why, but I'm very new to scripts so maybe it's something obvious. Any ideas?

Thank you :)

~ Added code tags ... Eric ~
soniajane
Poco Tourist
 
Posts: 40
Joined: Sun Apr 23, 2006 8:34 pm

Postby MarkB » Sat Feb 02, 2008 11:26 pm

Two suggestions. First change %m to %message throughout. Second, investigate whether you can accomplish what you need with an outgoing filter alone (and no script). A filter can "Change Account To" (i.e., change the X-Account header), "Remove Header" and "Add Header." For example, remove header From: and add header From: me <me@myworkdomain.com>.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby soniajane » Sat Feb 02, 2008 11:35 pm

Hi Mark,

Thanks for the reply. I did try using filters alone to change account and remove/add header elements as you suggest, but for reasons I couldn't figure out it just doesn't work.

I scanned the forums and it seems others have had this same difficulty which is where I got the idea of using scripts.

I'll try the %message tip though. Watch this space. :)
soniajane
Poco Tourist
 
Posts: 40
Joined: Sun Apr 23, 2006 8:34 pm

Postby MarkB » Fri Feb 08, 2008 2:31 am

Here I was, puzzling why emails in my Sent folder lately appeared to be coming from a secondary account and address. Of course, the answer is that I forgot to delete the outgoing filter that had been set up for testing. What a doofus.

Any news, soniajane?
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby soniajane » Fri Feb 08, 2008 2:38 am

Ooops - sorry for not getting back as I'd promised. :oops:

But I don't have good news. Changing to %message didn't seem to make any difference. I still can't get it to work.

The filter seems to trigger OK, and strangely enough if I send a message to myself (on my work email address), when I hit 'reply' it does tee up the correct return address which suggests that the change of account is somehow working.

But even if I do the remove and add header information on 'from' and 'reply to' - in the sent email the header information still shows my personal email address instead of my work one, which is what I'm trying to avoid.

I don't know if I've explained that clearly - it makes sense to me, but then I'm in my own head :lol:
soniajane
Poco Tourist
 
Posts: 40
Joined: Sun Apr 23, 2006 8:34 pm

Postby MarkB » Fri Feb 08, 2008 4:06 am

For me, the outgoing filter described below appears to do what you want. Names and addresses have been changed obviously. Mail sent from Poco to a webmail account looks like it came from the "work" account and address. Replies from the webmail look right. Replies to the reply from Poco to webmail look right.

Code: Select all
Outgoing Filter

Filter messages for My Personal Account Matching all characters
Search Account name for My Personal Account
Perform change account to My Business Account
and
Perform remove header From:
and
Perform add header From: me <me@myworkaddress.com>
and
Perform remove header Reply-To:
and
Perform add header Reply-To: me@myworkaddress.com

The "change account to" can probably be removed. The account header makes no sense to the recipient, and the recipient's mailer seems to remove it from replies anyway.
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron