Categories
cPanel

Email accounts disappeared in cPanel

I am unsure why, but most likely this comes through via some sort of exploit of a plugin a user has. I have seen email accounts disappear in cPanel users email accounts page. Yet their email functions fine. I found this article and it spoke a little about the issue:

https://support.cpanel.net/hc/en-us/articles/360052477034-Email-accounts-are-missing

I found it was easiest to lay it out. My example shows user anthony@vivithemage.com was not there, and this is how to restore it. If you have the passwd file or if you recall what the usernames of the email accounts should be, you can get them back showing in cPanel to modify them. This will show you what user had an email account:

[root@madhost613 vivithemage.com]# cat /home/vivithem/etc/vivithemage.com/passwd
anthony:x:671:673::/home/vivithem/mail/vivithemage.com/anthony:/usr/local/cpanel/bin/noshell
[root@madhost613 vivithemage.com#

Or you can pull it out from your email_accounts.json file:

[root@madhost613 vivithemage.com]# cat /home/vivithem/.cpanel/email_accounts.json
{"vivithemage.com":{"quota_mtime":1676555934,"disk_mtime":1676530335,"account_count":1,"shadow_mtime":1676555934,"accounts":{"anthony":{"suspended_login":0,"disk_mtime":1494927201,"diskused":"8041555","diskmtime":1676530335}}},"__version":3,"vivithemage.net":{"accounts":{},"account_count":0},"vivithemage.org":{"accounts":{},"account_count":0}}
[root@madhost613 vivithemage.com]#

now create a new shadow file in the correct directory and change ownership to the ACCOUNT. In my case it is:

cd /home/vivithem/etc/vivithemage.com/
chown vivithem:vivithem shadow

and dump this line in for EACH user missing:

anthony:$6$eGMpFjEJEI3349z3$.dhfm1rs/ftxFa8Rt8zs4yAA5dHCBdOb7P2T42Pwi/i5GpXb45BjoXiDccRbtmrwwoQkAHWF3mOwOouloYvvS1:18635::::::

If you have a second user with Elyssa you would now have this:

anthony:$6$eGMpFjEJEI3349z3$.dhfm1rs/ftxFa8Rt8zs4yAA5dHCBdOb7P2T42Pwi/i5GpXb45BjoXiDccRbtmrwwoQkAHWF3mOwOouloYvvS1:18635::::::
elyssa:$6$eGMpFjEJEI3349z3$.dhfm1rs/ftxFa8Rt8zs4yAA5dHCBdOb7P2T42Pwi/i5GpXb45BjoXiDccRbtmrwwoQkAHWF3mOwOouloYvvS1:18635::::::

replace anthony with your username missing from passwd. The hash following is irrelevant, because once you do this, you can change the password via cPanel as you would normally.

Once done this auto populates them in cPanel with no restarts required. It’s a bit of a manual process, but at least this way you can get back on with your life and reset passwords.

Categories
cPanel linux

How to delete all mail in queue for cPanel exim

I ran into an issue where a user was spamming and queue up thousands of email in our cPanel server. To clear it out, I did this:

/etc/init.d/exim stop

exim -bpru | awk {'print $3'} | xargs exim -Mrm

or

exim -bpru|grep frozen|awk {'print $3'}|xargs exim -Mrm

/etc/init.d/exim start

I had about 120k emails in queue and it took about 20 seconds to remove them all. If you want to fine tune it, you can have exim delete only specific emails in queue:

grep -lr 'a certain string' /var/spool/exim/input/ | \sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' | xargs exim -Mrm

Credit to: http://bradthemad.org/tech/notes/exim_cheatsheet.php
 

To delete frozen emails from a specific email address:

exiqgrep -i -f luser@example.tld | xargs exim -Mrm

If you just want to delete mail queue directories, sometimes faster delete:

/var/spool/exim/input and the /var/spool/exim/msglog directories

Categories
cPanel linux

Fatal error: Allowed memory size of 134217728 bytes exhausted – MySQL error – PHPMyAdmin

I had a client trying to import a 200M zip file to phpmyadmin to import into his MySQL database, he kept receiving this error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 201380904 bytes) in /usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/zip_extension.lib.php on line 65

It ends up that phpmyadmin is using its own php.ini config, and defaults the memory size to 128M.

Edit the file : /usr/local/cpanel/3rdparty/etc/php.ini.dist

there is a line that says memory_limit, change that to what you’d like. I changed mine to 264M.

You will want to restart cPanel as well:

/etc/init.d/cpanel restart

You will lose this setting upon reboot, so if you want to keep it, you will want to run this:

echo "/usr/local/cpanel/3rdparty/etc/php.ini.dist" >> /etc/cpanelsync.exclude

This will exclude the file when it goes to sync/update with cPanel.

Categories
cPanel linux

Copying cPanel resller account to cPanel server with root access

So I was in the process of moving a users cPanel account from an old server where he only had Reseller access to, on to my server, where I have root access. Typically you can use the method of the built in transfer within cPanel, but it is required you have root access on both servers. Because of this, it makes reseller accounts tricky. We need to do the following :

On the old server, where you have the reseller, or shared account :

1. Login to accounts cpanel www.domain.com/cpanel (or http://10.10.10.10.:2082)

2. You will then search for backups and hit enter

3. Now click on back up wizard option

[zp src=”reseller.jpg” album=”blog/cpanel/transfers/” width=”600″]

You can select wherever you would like to store it, but I prefer to jut SCP it right over to my new server.

on the new server, where you have root access :

1. Login to your server via SSH using something like putty

2. cd /home

3. wget http://domain.com/backup-1.30.2007_06-36-16_durbidge

4. log in to WHM & /Backup Restore a Full Backup/cpmove file

Note that you do need to 0777 the back up file, or you will run into permission issues when copying (if doing the backup to HOME DIR).

If you want to re-assign the reseller account, you do need to go to the reseller central, and apply the accounts to the reseller that owns them now.