LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Send email to specific SMTP servers per email from my server? (https://www.linuxquestions.org/questions/linux-server-73/send-email-to-specific-smtp-servers-per-email-from-my-server-735168/)

neilius 06-24-2009 12:19 AM

Send email to specific SMTP servers per email from my server?
 
First post here:

I have a linux based system as a web server with php/mySQL and provide a service to my clients that allows them to send individual emails to their own clients as part of managing their vacation rental business. Currently I send the email from my server using sendmail and change the reply-to field to my client's email address.

What I want to do to instead is send the email via my client's own email account to avoid my server potentially being blacklisted and to reduce the chance of the email being considered spam. I would collect their own mail server details and just need a way to get the emails that I currently send via sendmail re-directed to their own server for sending.

I am not a mail expert and so perhaps what I'm asking is really easy to do and I'm being blinded by my current use of sendmail? Can anyone suggest the right way to do this?

Many Thanks
Neilius

PS: I don't have linux "users" defined for my clients - just in my web application.

fotoguy 06-24-2009 03:38 AM

Sounds like you are needing a mail relay, you can setup sendmail as a mail relay for your clients domains, it will send and receive mail to and from their servers. Your server will effectively receive then forward the mail without having to change any email addresses, domain names etc.

For security reasons, sendmail does not relay mail by default, this is typically used by spammers, you will need to add all the domains you want to relay into a file, you will need to do a google search on setting up a relay for sendmail.

Hope this points you in the right direction

neilius 06-24-2009 09:28 AM

Quote:

Originally Posted by fotoguy (Post 3584322)
Sounds like you are needing a mail relay, you can setup sendmail as a mail relay for your clients domains, it will send and receive mail to and from their servers. Your server will effectively receive then forward the mail without having to change any email addresses, domain names etc.

For security reasons, sendmail does not relay mail by default, this is typically used by spammers, you will need to add all the domains you want to relay into a file, you will need to do a google search on setting up a relay for sendmail.

Hope this points you in the right direction

Thanks fotoguy.

I'd looked into this and concluded that if my clients were using, say, gmail as their mailing address then I would have to add the gmail.com domain to the list - and surely that will open up my server for considerable abuse - unless there's some way to restrict it.

Also, my client's will be initiating email from my server and not their normal email account login - I effectively need to get the email in my system to their (eg. gmail) email servers somehow.

In my mind, when one sets up an email client one enters the server info for incoming and outgoing email. Ideally I need a commandline way of sending an email via a particular smtp server each time that I invoke it. Maybe there's a way of specifying the smtp server as commandline args (to sendmail or some other mailer) or some file config that I can specify that makes the mailer choose the correct smtp server based upon the "from" email address? I have seen the 'SMART_HOST' feature in sendmail but that appears to be a single SMTP server for all emails.

Does that make more sense now?

Thanks,
Neil

luisduenas 06-24-2009 09:58 AM

Quote:

Originally Posted by neilius (Post 3584736)
Currently I send the email from my server using sendmail and change the reply-to field to my client's email address.

is only one customer( one domain ) or several domains ??
and how you change that ? ( I suppose using PHP-from not command line)

Quote:

Originally Posted by neilius (Post 3584736)
What I want to do to instead is send the email via my client's own email account

I think you did it allready, or you mean their own email server ?

Quote:

Originally Posted by neilius (Post 3584736)
avoid my server potentially being blacklisted and to reduce the chance of the email being considered spam.

Your server ip address is going to be the ip address originator always, no matter what you change.

but the smart host could help to reduce the risk if the smart host , has the antispam , rate limit , antivirus control.

But as you say you dont want it.


use PHP whit SMTP Authentication to send e-mails.
Your customers have to use their e-mail servers, user, password.
For last be sure to disable the MTA to external email.

script example.
http://email.about.com/od/emailprogr...t/et073006.htm

neilius 06-24-2009 10:35 AM

I think I've found something that will do what I need at: http://www.phpguru.org/downloads/Rma...l%20for%20PHP/

Not tried/tested it yet but purports to have a send option via SMTP as well as mail() or sendmail(). Looks like I can bypass sendmail and do a direct SMTP send.

Thanks for your help.
Neilius

neilius 06-24-2009 10:44 AM

Quote:

Originally Posted by luisduenas (Post 3584762)
is only one customer( one domain ) or several domains ??
and how you change that ? ( I suppose using PHP-from not command line)

I think you did it allready, or you mean their own email server ?


Your server ip address is going to be the ip address originator always, no matter what you change.

but the smart host could help to reduce the risk if the smart host , has the antispam , rate limit , antivirus control.

But as you say you dont want it.


use PHP whit SMTP Authentication to send e-mails.
Your customers have to use their e-mail servers, user, password.
For last be sure to disable the MTA to external email.

script example.
http://email.about.com/od/emailprogr...t/et073006.htm

Ah, thanks! It looks like the PEAR package referenced here is an alternative to the Rmail solution that I just located. I'll check that out further.

I have at least 2 solution now :)

Cheers,
Neilius

fotoguy 06-25-2009 06:31 AM

Ok getting a better understanding now on what you want. Yes opening up to a domain like gmail.com would allow all users of that domain access to your server, to safe guard this you would use white and blacklists. You could blacklist the whole gmail.com domain, then only allow specific email address through the relay.

If you need to use the command line, I use a little perl script, which is an email client, for all my admin tasks on my web/mail server called 'sendEmail'. This allows you to send email with any email address you specify as the sender or receiver, also can send to any smtp server. I use this in conjunction with bash scripts, this may be worth checking out.


All times are GMT -5. The time now is 12:29 AM.