Showing posts with label Mails. Show all posts
Showing posts with label Mails. Show all posts
How to clear sendmail queue
Posted by Unknown at 22:14 0 comments
If you are using Linux operating system, you can clear the sendmail queue by the following ways -
1. manually: delete /var/spool/mail/*.* files in this dir –> delete /var/mqueue/*.* files all mail will be deleted. then, using mailq command, confirm whether all the mails are cleared
2. using command: use simple command sendmail -v -q in root prompt. it will clear all pending mails. you can also confirm by running mailq command
If you are interested in deleting particular domain or user or recepitience mail, use this command sendmail -qS -v test.com – deletes all mail from *@test.com sendmail -qR -v hotmail.com – deletes all mail from recepient of hotmail
1. manually: delete /var/spool/mail/*.* files in this dir –> delete /var/mqueue/*.* files all mail will be deleted. then, using mailq command, confirm whether all the mails are cleared
2. using command: use simple command sendmail -v -q in root prompt. it will clear all pending mails. you can also confirm by running mailq command
If you are interested in deleting particular domain or user or recepitience mail, use this command sendmail -qS -v test.com – deletes all mail from *@test.com sendmail -qR -v hotmail.com – deletes all mail from recepient of hotmail
Restoring emails for a Parked domain
Posted by Unknown at 07:43 0 comments
Following assumptions have been made in this case :
Parked domain : abc.com
New account : xyz.com ( Username=xyz)
1. Re-create all the email accounts after parking the domain abc.com on xyz.com.
2. There would be a folder named ‘abc.com’ under the new account at the following path :
Replace that folder with the corresponding folder available in the original backup.
Parked domain : abc.com
New account : xyz.com ( Username=xyz)
1. Re-create all the email accounts after parking the domain abc.com on xyz.com.
2. There would be a folder named ‘abc.com’ under the new account at the following path :
/home/xyz/mail/
Replace that folder with the corresponding folder available in the original backup.
Script to email successful Ftp logins
Posted by Unknown at 18:33 0 commentsShell Script to email Successful Ftp Logins.
Note: This script will work with Pure-Ftpd server. You will have to edit the search string a bit according to your Ftp server.
This Shell script will search the server logs on daily basis and will email you the successful Ftp Logins of the day. The ftp logs are saved in the /var/log/messages file as by default there is no separate log file for Ftp in Linux.
Create a file /home/script/ftplogins.sh and paste the below code:
#!/bin/bash
#Retrieve the current date
CUR_DATE=`date | awk ‘{print $2? ” $3}’`
#Create a temporary file to store the logs
touch /tmp/out.txt
echo “Successful Ftp Logins on “$CUR_DATE”" > /tmp/out.txt
#Search the successful attempts and save in the temporary file
/bin/grep “$CUR_DATE” /var/log/messages | grep pure-ftpd | grep login >> /tmp/out.txt
#Email the contents of the file to your email address
/bin/mail -s “Successful Ftp Login Attempts on “$CUR_DATE” ” youremail@yourdomain.com < /tmp/out.txtSave the file. You now have to schedule a cron to execute the file once in a day to search logs. Edit the cron file
crontab -eand add the following cron job
59 23 * * * /bin/sh /home/script/ftologins.sh
SquirrelMail Error
Posted by Unknown at 06:10 0 comments
**Error :
root@fs1 [/scripts]# ./fixwebmail
chown: cannot access `/usr/local/etc/cpanel/base/webmail/data’: No such file or directory
chmod: cannot access `/usr/local/etc/cpanel/base/webmail/data’: No such file or directory
1) Try Unchecking HordeMail & SquirrelMail in WHM >> Tweak Settings >> Save >> Re-check >> Save
Try now …………
2) Hey,
Is there any usecpphp file in /var/cpanel/ directory?.
If no create it by the following command
touch /var/cpanel/usecpphp
If the file is exist, run the following commands,
cp -p /usr/local/cpanel/base/3rdparty/squirrelmail/config/config_default.php /usr/local/cpanel/base/3rdparty/squirrelmail/config/config.php
I hope this will solve your problem. If problem exists run the following commands.
/scripts/updatenow
/scripts/makecpphp
root@fs1 [/scripts]# ./fixwebmail
chown: cannot access `/usr/local/etc/cpanel/base/webmail/data’: No such file or directory
chmod: cannot access `/usr/local/etc/cpanel/base/webmail/data’: No such file or directory
1) Try Unchecking HordeMail & SquirrelMail in WHM >> Tweak Settings >> Save >> Re-check >> Save
Try now …………
2) Hey,
Is there any usecpphp file in /var/cpanel/ directory?.
If no create it by the following command
touch /var/cpanel/usecpphp
If the file is exist, run the following commands,
cp -p /usr/local/cpanel/base/3rdparty/squirrelmail/config/config_default.php /usr/local/cpanel/base/3rdparty/squirrelmail/config/config.php
I hope this will solve your problem. If problem exists run the following commands.
/scripts/updatenow
/scripts/makecpphp
Preventing nobody spammer in PHP
Posted by Unknown at 22:17 0 commentspreventing nobody spammer in PHP
PHP and Apache has a history of not being able to track which users are sending out mail through the PHP mail function from the nobody user causing leaks in formmail scripts and malicious users to spam from your server without you knowing who or where.
Watching your exim_mainlog doesn’t exactly help, you see th email going out but you can’t track from which user or script is sending it. This is a quick and dirty way to get around the nobody spam problem on your Linux server.
If you check out your PHP.ini file you’ll notice that your mail program is set to: /usr/sbin/sendmail and 99.99% of PHP scripts will just use the built in mail(); function for PHP – so everything will go through /usr/sbin/sendmail =)
Requirements:
We assume you’re using Apache 1.3x, PHP 4.3x and Exim. This may work on other systems but we’re only tested it on a Cpanel/WHM Red Hat Enterprise system.
Time:
10 Minutes, Root access required.
Step 1)
Login to your server and su – to root.
Step 2)
Turn off exim while we do this so it doesn’t freak out.
/etc/init.d/exim stop
Step 3)
Backup your original /usr/sbin/sendmail file. On systems using Exim MTA, the sendmail file is just basically a pointer to Exim itself.
mv /usr/sbin/sendmail /usr/sbin/sendmail.hidden
Step 4)
Create the spam monitoring script for the new sendmail.
pico /usr/sbin/sendmail
Paste in the following:
#!/usr/local/bin/perl
# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, “>>/var/log/spam_log”) || die “Failed to open file ::$!”;
my $uid = $>;
my @info = getpwuid($uid);
if($REMOTE_ADDR) {
print INFO “$date – $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME n”;
}
else {
print INFO “$date – $PWD – @infon”;
}
my $mailprog = ‘/usr/sbin/sendmail.hidden’;
foreach (@ARGV) {
$arg=”$arg” . ” $_”;
}
open (MAIL,”|$mailprog $arg”) || die “cannot open $mailprog: $!n”;
while ( ) {
print MAIL;
}
close (INFO);
close (MAIL);
Step 5)
Change the new sendmail permissions
chmod +x /usr/sbin/sendmail
Step 6)
Create a new log file to keep a history of all mail going out of the server using web scripts
touch /var/log/spam_log
chmod 0777 /var/log/spam_log
Step 7)
Start Exim up again.
/etc/init.d/exim start
Step 8) Monitor your spam_log file for spam, try using any formmail or script that uses a mail function – a message board, a contact script.
tail – f /var/log/spam_log
Sample Log Output
Mon Apr 11 07:12:21 EDT 2005 – /home/username/public_html/directory/subdirectory – nobody x 99 99 Nobody / /sbin/nologin
Log Rotation Details
Your spam_log file isn’t set to be rotated so it might get to be very large quickly. Keep an eye on it and consider adding it to your logrotation.
pico /etc/logrotate.conf
FIND:
# no packages own wtmp — we’ll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
ADD BELOW:
# SPAM LOG rotation
/var/log/spam_log {
monthly
create 0777 root root
rotate 1
}
Notes:
You may also want to chattr + i /usr/sbin/sendmail so it doesn’t get overwritten.
Enjoy knowing you can see nobody is actually somebody =)
Mail Error message: Error 550 – “The recipient cannot be verified”:
Posted by Unknown at 18:06 0 comments
PERM_FAILURE: SMTP Error (state 9): 550-"The recipient cannot be verified.
Please check all recipients of this550 message to verify they are valid.
-----------------------
If the email account does indeed exist, then it is need to run the following commands to correct the issue.
Please check all recipients of this550 message to verify they are valid.
-----------------------
If the email account does indeed exist, then it is need to run the following commands to correct the issue.
/scripts/updateuserdomains
/scripts/mailperm
/scripts/mailperm
Spamd Failing
Posted by Unknown at 18:05 0 comments
If you find the "spamd" failing error on an exim restart.
root@server [~]# /etc/init.d/exim restart
Shutting down exim: [ OK ]
Shutting down antirelayd: [ OK ]
Shutting down spamd: [ FAILED ]
Starting exim-26: [ OK ]
Starting exim: [ OK ]
Starting exim-smtps: [ OK ]
Starting antirelayd: [ OK ]
Then use he following steps
When disabling "spamd", the Cpanel create a file named "/etc/spamdisable" which may not get deleted on enabling the "spamd" feature again. Check the presence of the above said file.
The issue may also arise due to unavailability of the perl module "Mail::SpamAssassin" by installing the the same and on restarting the exim, the issue will be fixed.
# /scripts/perlinstaller --force Mail::SpamAssassin
#/etc/init.d/exim restart
root@server [~]# /etc/init.d/exim restart
Shutting down exim: [ OK ]
Shutting down antirelayd: [ OK ]
Shutting down spamd: [ FAILED ]
Starting exim-26: [ OK ]
Starting exim: [ OK ]
Starting exim-smtps: [ OK ]
Starting antirelayd: [ OK ]
Then use he following steps
When disabling "spamd", the Cpanel create a file named "/etc/spamdisable" which may not get deleted on enabling the "spamd" feature again. Check the presence of the above said file.
The issue may also arise due to unavailability of the perl module "Mail::SpamAssassin" by installing the the same and on restarting the exim, the issue will be fixed.
# /scripts/perlinstaller --force Mail::SpamAssassin
#/etc/init.d/exim restart
110 Can’t open SMTP stream
Posted by Unknown at 05:48 0 comments
I found the config for cpanel’s SM:
/usr/local/cpanel/base/3rdparty/squirrelmail/config/config.php
I just changed:
$useSendmail = false;
to:
$useSendmail = true;
(around line 33)
This will probably get written over with the next cpanel update, but it at least helps get my users sending mail again for
/usr/local/cpanel/base/3rdparty/squirrelmail/config/config.php
I just changed:
$useSendmail = false;
to:
$useSendmail = true;
(around line 33)
This will probably get written over with the next cpanel update, but it at least helps get my users sending mail again for
How To Add DomainKeys and SPF Records on CPanel Servers
Posted by Unknown at 20:46 0 comments
This how to describe how to add domainkeys and SPF (Sender Policy Framework) records on CPanel Servers. Whenever you create a domain on CPanel server using WHM, it wont add domainkeys and SPF records for particular domains. To add domainkeys and SPF records please use following steps.
We consider here we have a domain sohailriaz.com with cpanel username sohailri
Please note on CPanel servers most of the work is done using cpanel username which then reflect setting on particular domains. If you have several domains / sub domains under one username, it will add domainkeys and SPF records for all domains / subdomains.
Execute the following command on your CPanel server using root.
where sohailri is a username
If you wish to add DomainKeys for all Cpanel users on your server, execute following command.
If you want to add SPF records for all cpanel accounts exist on your server then use the following command.
If you want to add DomainKeys and SPF for every new account created on Cpanel, then do the following.
postwwwacct is a file which execute after wwwacct (used to create account), paste following lines in the file
We consider here we have a domain sohailriaz.com with cpanel username sohailri
Please note on CPanel servers most of the work is done using cpanel username which then reflect setting on particular domains. If you have several domains / sub domains under one username, it will add domainkeys and SPF records for all domains / subdomains.
Execute the following command on your CPanel server using root.
1 DomainKeys
1.1 Add DomainKeys for single user
/usr/local/cpanel/bin/domain_keys_installer sohailri
where sohailri is a username
1.2 Add DomainKeys for all CPanel users.
If you wish to add DomainKeys for all Cpanel users on your server, execute following command.
ls /var/cpanel/users | while read a; do
/usr/local/cpanel/bin/domain_keys_installer $a
done
2 SPF (Sender Policy Framework)
2.1 Add SPF for single account.
/usr/local/cpanel/bin/spf_installer sohailri
2.2 Add SPF for all Cpanel accounts.
If you want to add SPF records for all cpanel accounts exist on your server then use the following command.
ls /var/cpanel/users | while read a; do
/usr/local/cpanel/bin/spf_installer $a
done
3 Enable DomainKeys and SPF for every new CPanel account.
If you want to add DomainKeys and SPF for every new account created on Cpanel, then do the following.
vi /scripts/postwwwacct
postwwwacct is a file which execute after wwwacct (used to create account), paste following lines in the file
#!/usr/bin/perl
my %OPTS = @ARGV;
$ENV{USER} = “$OPTS{‘user’}”;
system q(/usr/local/cpanel/bin/domain_keys_installer $USER);
system q(/usr/local/cpanel/bin/spf_installer $USER);
Cannot send emails- RoundCube just shows “Sending Message”
Posted by Unknown at 13:03 0 comments
I found a problem with Roundcube, it shows sending message and hangs up there and actually it doesn’t send message anymore. I found the following solution here.
Problem with Roundcube, installed when updated to newest CURRENT release. – Page 3 – cPanel Forums:
vi /usr/local/cpanel/base/3rdparty/roundcube/config/main.inc.php
and changed
$rcmail_config['smtp_user'] = ‘%u’;
to
$rcmail_config['smtp_user'] = ”;
Problem with Roundcube, installed when updated to newest CURRENT release. – Page 3 – cPanel Forums:
vi /usr/local/cpanel/base/3rdparty/roundcube/config/main.inc.php
and changed
$rcmail_config['smtp_user'] = ‘%u’;
to
$rcmail_config['smtp_user'] = ”;
How to block emails from a specific address using Exim
Posted by Unknown at 07:16 1 comments
This is fairly easy to achieve with Exim.
First you’ll need to find the system filter file for Exim. This can be found out through WHM >> Main >> Service Configuration >> Exim Configuration Editor.
Towards the middle of the page, under the section ‘Filters’ , you ‘ll find the path to the file.
Open that file via SSH using your favorite editor and add the following to it :
If you would like a copy of the email to be sent to you after the message fails, use the following code :
Make sure that you substitute the correct email addresses in the above code.
First you’ll need to find the system filter file for Exim. This can be found out through WHM >> Main >> Service Configuration >> Exim Configuration Editor.
Towards the middle of the page, under the section ‘Filters’ , you ‘ll find the path to the file.
Open that file via SSH using your favorite editor and add the following to it :
if first_delivery
and ( (”$h_from:” contains “emailtoblock@domainname.com”)
)
then fail
endif
If you would like a copy of the email to be sent to you after the message fails, use the following code :
if first_delivery
and ( (”$h_from:” contains “emailtoblock@domainname.com”)
)
then
unseen deliver “youremail@yourdomainname.com”
fail
endif
Make sure that you substitute the correct email addresses in the above code.
Subscribe to:
Posts (Atom)