Send email to specific SMTP servers per email from my server?
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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
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
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.