dzaretsky 1 Posted October 13, 2022 Report Share Posted October 13, 2022 Through Google Workspace, I've set up an email alias as the default for my gmail account. I'd like to use this email alias for outgoing emails from X2. However, it seems to ignore the alias and sends emails using the original account email. I did figure out a workaround that requires 2 adjustments to the X2 code: 1. A separate "user" login entry is required for Google to distinguish between the email and login. In /protected/models/embedded/GMailAccount.php, add the "user" input in the functions below: public function attributeLabels(){ return array( 'senderName' => Yii::t('app','Sender Name'), 'email' => Yii::t('app','Email Address'), 'user' => Yii::t('app', 'Google ID'), 'password' => Yii::t('app','Password'), 'imapPort' => Yii::t('app','IMAP Port'), 'imapServer' => Yii::t('app','IMAP Server'), 'imapSecurity' => Yii::t('app','IMAP Security'), 'imapNoValidate' => Yii::t('app','Disable SSL Validation'), 'disableInbox' => Yii::t('app','Disable Email Inbox'), ); } public function renderInput ($attr) { switch($attr){ case 'user': case 'email': echo '<p class="fieldhelp-thin-small">'.Yii::t('app', '(example@gmail.com)'). '</p>'; echo CHtml::activeTextField($this, $attr, $this->htmlOptions($attr)); break; case 'password': echo X2Html::x2ActivePasswordField ($this, $attr, $this->htmlOptions ($attr), true); break; default: parent::renderInput ($attr); } } public function renderInputs(){ $this->password = null; echo CHtml::activeLabel($this, 'senderName'); $this->renderInput ('senderName'); echo CHtml::activeLabel($this, 'email'); $this->renderInput ('email'); echo CHtml::activeLabel ($this, 'user'); $this->renderInput ('user'); echo CHtml::activeLabel($this, 'password'); $this->renderInput ('password'); echo '<br/>'; echo '<br/>'; echo CHtml::tag ('h3', array (), Yii::t('app', 'IMAP Configuration')); echo '<hr/>'; echo CHtml::activeLabel($this, 'imapPort'); $this->renderInput ('imapPort'); echo CHtml::activeLabel($this, 'imapSecurity'); $this->renderInput ('imapSecurity'); echo CHtml::activeLabel($this, 'imapNoValidate'); $this->renderInput ('imapNoValidate'); echo CHtml::activeLabel($this, 'imapServer'); $this->renderInput ('imapServer'); echo CHtml::activeLabel($this, 'disableInbox'); $this->renderInput ('disableInbox'); echo CHtml::errorSummary($this); } public function rules(){ return array( array('email','email'), array('senderName,user,email,password', 'required'), array('senderName,user,email,password,imapPort,imapSecurity,imapNoValidate,imapServer,disableInbox', 'safe'), ); } 2. The "user" login needs to be added to the imap login. In protected/modules/emailInboxes/models/EmailInboxes.php, pass the auth->user instead of auth->email. /** * Initialize a mailbox and connect via IMAP * @return boolean Whether the IMAP connection was successfully initialized */ public function open($folder = "INBOX") { $this->setCurrentFolder ($folder); $cred = $this->credentials; $this->_imapStream = @imap_open( $this->encodeMailboxString($this->mailbox.$folder), !empty($cred->auth->user) ? $cred->auth->user : $cred->auth->email, $cred->auth->password); if (is_resource($this->_imapStream)) { $this->_open = true; return true; } return false; } I've tested these changes and seem to be working now. 1 Quote Link to post Share on other sites
jack 30 Posted October 14, 2022 Report Share Posted October 14, 2022 Hi Dzaretsky, Thanks for the post, I'll look into adding something to fix this in a newer update. -Jack Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.