~ overflow ~

Tag: email

Change sendmail’s outgoing ip

by admin on Apr.16, 2011, under Linux Happyness

Problem:

How to change sendmail’s outgoing ip?

Solution:

This is the ip that will be used to deliver messages, this ip might get blacklisted if one of your happy clients on a shared server decides to send a mass email.
Sendmail is always a bitch to config, but this time it wasn’t, just change your .m4 file adding:

CLIENT_OPTIONS(`Addr=123.456.789')dnl

rebuild the .cf file, restart sendmail and you’re done. In my case, I had a specific ip on the server that got “temporary” (permanently) blocked by gmail. Although new mail wasn’t being sent after the flood, google never unblocked my server, even after a week i still getting “limit rate exceeded” messages. Since I have many IPs on the server it was easier just to bind sendmail to another IP.

Source:

Server Fault

Leave a Comment :, , , more...

email validator snippet

by z3n on Dec.04, 2010, under Coding

Problem:

How to validate an email using php?

Solution:

I’m posting this function because i made it to have older php compatibility.

function email_validator($email) {
	return function_exists("filter_var") ?
			filter_var($email, FILTER_VALIDATE_EMAIL)
		: // if filter_var is not defined (php < 5.2), we will emulate php's core here
			!empty($email) && strlen($email) <= 320 &&
			/**
			 * preg info:
			 *
			 * Copyright © Michael Rushton 2009-10
			 * http://squiloople.com/
			 *
			 * more at: http://svn.php.net/viewvc/php/php-src/trunk/ext/filter/logical_filters.c?view=markup
			 */
			preg_match("/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD", $email)
	;
}
Leave a Comment :, , more...

preg (regular expression) to get emails in php

by z3n on Aug.28, 2010, under Coding

Problem:

A regular experssion pattern for getting emails on a random string.

Solution:

preg_match_all(
	"/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i",
	$string,
	$matches,
	PREG_PATTERN_ORDER
);
Leave a Comment :, , , more...

Using telnet to access pop3 (retrieve emails) and smtp (send emails)

by z3n on Jan.11, 2010, under Uncategorized

Problem:

How to test retrieve and send emails by raw telnet?

Solution:

Retrieving emails (bold lines are the commands, italics are outputs)

telnet mail.yourserver.com 110
Trying 1.2.3.4…
Connected to mail.yourserver.com.
Escape character is ‘^]’.
+OK Dovecot ready.
user your_email@yourserver.com
+OK
pass your_password
+OK Logged in.
list
+OK 1 messages:
1 1133

.

retr 1

message

.

quit

Sending emails:

telnet mail.youremailserver.com 25
Trying 1.2.3.4…
Connected to mail.youremailserver.com.
Escape character is ‘^]’.
220 youremailserver.com ESMTP Postfix

helo yourdomain.com
250 youremailserver.com
auth login
334 VXNlcm5hbWU6
eW91cmVtYWlsQHlvdXJkb21haW4uY29t (youremail@yourdomain.com base64 encoded)
334 UGFzc3dvcmQ6
eW91cnBhc3N3b3Jk (yourpassword base64 encoded)
235 2.0.0 Authentication successful
mail from:youremail@yourdomain.com
250 2.1.0 Ok
rcpt to: someone@somedomain.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject: test

hi
.

250 2.0.0 Ok: queued as 8B65ED40075
quit
Note that there’s many different authentication protocols, base64 is the less secure one, some servers may require a better authentication mechanism, or even use an ecrypted port, which will not work with telnet, try open ssl instead.

Leave a Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!