dispo_send_email.php with mulitple gmail accounts (RESOLVED)

Any and all non-support discussions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

dispo_send_email.php with mulitple gmail accounts (RESOLVED)

Postby thephaseusa » Sat Mar 03, 2018 1:34 pm

Version: 2.14b0.5
SVN Version: 2872
DB Schema Version: 1527
ViciBox v.7.0.4| Asterisk 11.25.1-vici |
4 Box Cluster of 1 Database, 1 Asterisk, 1 Web, & 1 Archive Server.
Fundraising Call Center

I'm almost there. Here is my dilemma:

I want to send emails when my custom STATUS, EMAIL is coded. The problem is, I have it checked as a scheduled call back, which I want, so the status in asterisk shows up as CBHOLD. Some scheduled call backs need an email, some don't. Is there a way I could get my custom status EMAIL to show up in vicidial_list in asterisk as EMAIL instead of CBHOLD?

I noticed incoming calls weren't being emailed and thought something was amiss, till I thought of going to the INGROUP and setting the dispo url field there. What a feature rich dialing solution! Amazing!

Thanks WC for the advice on postfix gmail relaying, got that working today!

John Merritt
Last edited by thephaseusa on Thu Mar 08, 2018 10:45 am, edited 1 time in total.
thephaseusa
 
Posts: 345
Joined: Tue May 16, 2017 2:23 pm

Re: dispo_send_email.php

Postby blackbird2306 » Sun Mar 04, 2018 6:54 am

No, there is no way around to change the status without breaking callback functionality. It's hard coded process that scheduled callback status turns into CBHOLD until it has not hit it's trigger time. After that time your CBHOLD status reverts back to your initial status EMAIL (this happens only with everyone not with useronly). But you are able to see this initial status in modify lead page at "CALLS TO THIS LEAD" at first position. Or just make a custom field with checkbox/radio button (EMAIL sent? Yes / No) which the agents must fill out. Maybe in combination with feature "Field Required"? Unfortunately it's not possible yet to use this feature only for a certain selected status.
Field Required -If the campaign option allowing required fields is also enabled, this field allows you to force an agent to fill in this field before they can hang up the call. Y will affect all calls, INBOUND_ONLY will only affect calls received by the agent through an In-Group. This option will only work for the following custom field types: TEXT, AREA, DATE, SELECT, MULTI, RADIO, CHECKBOX. Default is N.
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm

Re: dispo_send_email.php

Postby thephaseusa » Sun Mar 04, 2018 3:52 pm

Thanks Blackbird! I was afraid that would be tricky, so I've decided for now that if it's a CBHOLD, and the agent wants an email sent, he will fill out the email address, and it will get sent. If he codes it a 3 Call Back, as long as the email field isnt filled out, they won't get an email. If the field is already filled out, they will get the email, but that may be not a bad idea anyway. Another question if I may?

I have email on dispo working for 1 gmail address. I tried adding 2 more into the sasl_passwd file and it threw the error, duplicate entries. Is there any way to use multiple gmail emails for relaying? That is, I want to be able to use send from 3 gmail addresses. I made separate containers for each one, but when i try to use the other containers, it still has the send_from_email address as the first one.

Thanks. Кстати вы не русский?

Update:

A little progress, I found out how to stop postmap complaining about multiple entries for the gmail relay:

/etc/postfix/sasl_passwd:
# per-sender authentication
account1@gmail .com account1@gmail.com:passwd1
account2@gmail .com account2@gmail.com:passwd2

# default relayhost
[smtp.gmail.com]:587 default_account@gmail.com:default_passwd

/etc/postfix/sender_relay:
account1@gmail.com [smtp.gmail.com]:587
account2@gmail.com [smtp.gmail.com]:587

postmap sasl_passwd sender_relay

systemctl restart postfix

Now postmap doesnt complain, I thought everything would work. Emails go out on all 3 emails, but it still shows sender as default relay.

I notice I can specify the from address in sendmail and that works. I have a container set up for each email account, and that container name is specified in the dispo send email url. But Vicidial is reading the default relay in sasl_passwd and using that email address as the from address, regardless of what from email the container specifies.

I just read about gmail rewriting the from address of all emails relayed its accounts. Now im thinking I have 3 servers, I could configure postfix on each to relay to a different gmail address, and send the dispo_send_email url to that server. 3 gmail accounts, 3 postfix servers, each relaying to the specified gmail account.

Okay guys, that worked. I set up my db server to relay the 1st gmail address, my asterisk server to relay a 2nd gmail address, and my web server to relay a 3rd gmail address, different containers for each email, and pointed the dispo call url to the corresponding postfix server. This works for me right now, I'm only using 3 campaigns and 3 gmail addresses. If I had 10 or 20 different gmails I don't know how I would get that to work, or if its possible. But this worked for me.

John
thephaseusa
 
Posts: 345
Joined: Tue May 16, 2017 2:23 pm

Re: dispo_send_email.php

Postby blackbird2306 » Tue Mar 06, 2018 8:53 am

I found the solution for the problem with multiple email accounts. Go this way (it's a guide for the people here):
1. First start with this guide and make sure sending with e.g. gmail is working
http://www.vicidial.org/VICIDIALforum/viewtopic.php?f=2&t=38079#p132164

2. Change or generate file /etc/postfix/sasl_passwd:
Code: Select all
# per-sender authentication
account1@gmail .com account1@gmail.com:passwd1
account2@gmail .com account2@gmail.com:passwd2

# default relayhost account to use when no from sender is defined
[smtp.gmail.com]:587 default_account@gmail.com:default_passwd


3. change/generate file /etc/postfix/sender_relay (so far we are here same with your post):
Code: Select all
account1@gmail.com [smtp.gmail.com]:587
account2@gmail.com [smtp.gmail.com]:587


4. change /etc/postfix/main.cf:
Code: Select all
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# cert file depends on linux version e.g opensuse
smtp_tls_CAfile = /etc/ssl/ca-bundle.pem

#new part for different accounts
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay

5.
Code: Select all
chmod 600 /etc/postfix/sasl_passwd
cd /etc/postfix
postmap sasl_passwd sender_relay
"systemctl restart postfix" or "postfix reload"


6. Now test and ensure it's possible to send emails from linux shell with different accounts:
Code: Select all
# the part after -f "account1.." is the account from name defined in sender_relay file
echo "Subject: sendmail test" | sendmail -v -f "account1@gmail.com" -F "Testaccount1" recipient@web.de
#wait some minutes between the calls
echo "Subject: sendmail test" | sendmail -v -f "account2@gmail.com" -F "Testaccount2" recipient@web.de


7. Vicidial uses in dispo_send_email.php the native PHP mail function, which is sendmail command with usually "sendmail_path = /usr/sbin/sendmail -t -i" defined in php.ini. But the FROM header will be ignored in sendmail command and has no effect. So the default entry in sasl_passwd will be used (default_account@gmail.com)!

8. And now the trick thereby is in changing "dispo_send_email.php" file:
Code: Select all
// at line 1270 and 1278 there are two php mail commands, which we have to change:
// line 1270 paste --> , "-f".$email_from
if (mail($email_to, $email_subject, "", $header, "-f".$email_from))
   {echo "Sent";}

// line 1278 almost same
mail("$email_to","$email_subject","$email_body", "From: $email_from", "-f".$email_from);
//


After these changes you are now able to switch the outgoing email account in settings container:
email_from => account1@gmail.com
or
email_from => account2@gmail.com

PS:
Кстати вы не русский?
google says this is russian language, but I'm more from Europe :-)
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm

Re: dispo_send_email.php

Postby thephaseusa » Wed Mar 07, 2018 8:40 am

Thank you! Once I managed to copy your snippet, including the leading comma, it worked! Brilliant!

John
thephaseusa
 
Posts: 345
Joined: Tue May 16, 2017 2:23 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 63 guests