By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

PHP Email

P: n/a

Hello all,

How can i send email using PHP from my server ?
Which settings are necessary ?

please, guide me
Thanks in advance.

Apr 27 '07 #1
Share this Question
Share on Google+
17 Replies


P: n/a
Michael Vilain wrote:
In article <11**********************@u32g2000prd.googlegroups .com>,
pradeep <pw*******@gmail.comwrote:
>Hello all,

How can i send email using PHP from my server ?
Which settings are necessary ?

please, guide me
Thanks in advance.

RTFM:

http://us2.php.net/manual/en/ref.mail.php
First of all, do you have an SMTP server running on your server? Does
it require authentication?

Depending on what you have and what you need to do, the mail() function
could work fine. With other situations you might need a package such as
Pear Mail to make things easier.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 27 '07 #2

P: n/a
Max
I have a question related to this post:

We are using 2 different Linux based servers: one for web (PHP, MySQL)
and another for the mail (Qmail, SquirrelMail e.t.c.). Our webserver
is co-located and mail server is installed here. For the PHP mail()
function to be able to use the mail server, I modified php.ini for
SMTP to pointi to the mail server' IP. Yet it still uses web server's
sendmail as SMTP MTA.

Please help

Apr 27 '07 #3

P: n/a
Max wrote:
I have a question related to this post:

We are using 2 different Linux based servers: one for web (PHP, MySQL)
and another for the mail (Qmail, SquirrelMail e.t.c.). Our webserver
is co-located and mail server is installed here. For the PHP mail()
function to be able to use the mail server, I modified php.ini for
SMTP to pointi to the mail server' IP. Yet it still uses web server's
sendmail as SMTP MTA.

Please help
Did you define sendmail_path in your php.ini? Also, after changing your
php.ini, did you stop and restart your server?

What do you have for your sendmail parameters in your php.ini?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 28 '07 #4

P: n/a
pradeep schreef:
Hello all,

How can i send email using PHP from my server ?
Which settings are necessary ?
Apart from configuring the os i'd probably opt for
http://www.swiftmailer.org/
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Apr 28 '07 #5

P: n/a
Rik
Michael Vilain wrote:
In article <11**********************@s33g2000prh.googlegroups .com>,
Max <Ma*********@gmail.comwrote:
>I have a question related to this post:

We are using 2 different Linux based servers: one for web (PHP, MySQL)
and another for the mail (Qmail, SquirrelMail e.t.c.). Our webserver
is co-located and mail server is installed here. For the PHP mail()
function to be able to use the mail server, I modified php.ini for
SMTP to pointi to the mail server' IP. Yet it still uses web server's
sendmail as SMTP MTA.

Please help

That's not how UNIX email works. AFAIK, php.ini tells php where the
local mail transport agent (MTA) is located. php uses this to spawn a
thread or perhaps even fork() a process to deliver the mail to the MTA.
There's no provision to use "remote" MTAs.

You'll have to configure the local MTA on the web server to forward the
mail to the mail server if you want mail delivered.
Nonsense. PHP can just as easily use a third party SMTP server, as long
as it's configured properly, see Jerry's reply.

--
Rik Wasmus

Estimated date being able to walk again: 01-05-2007.
Less then a week, hurray!
Apr 28 '07 #6

P: n/a
Rik
Michael Vilain wrote:
In article <f0**********@news2.zwoll1.ov.home.nl>,
Rik <lu************@hotmail.comwrote:
>Michael Vilain wrote:
>>That's not how UNIX email works. AFAIK, php.ini tells php where the
local mail transport agent (MTA) is located. php uses this to spawn a
thread or perhaps even fork() a process to deliver the mail to the MTA.
There's no provision to use "remote" MTAs.

You'll have to configure the local MTA on the web server to forward the
mail to the mail server if you want mail delivered.
Nonsense. PHP can just as easily use a third party SMTP server, as long
as it's configured properly, see Jerry's reply.

OK, I'll say it --slowly-- for you. AFAIK, php.ini won't allow
configuration to a REMOTE SMTP server on LINUX or UNIX systems.
Je m'excuse. Indeed the only hosts where I had to use a different SMTP
seem to be Windows hosts.... Where it's no problem to use a different one.
--
Rik Wasmus

Estimated date being able to walk again: 01-05-2007.
Less then a week, hurray!
Apr 29 '07 #7

P: n/a
Max
I have read the php.net mail manual and am aware of the SMTP MTA
Windows redirect. The manual reads that php.ini SMTP string can be
configured for Windows servers only. I am aware of that. What I am
trying to accomplish is - to make it work in Linux setup.

Here is our scenario:

We have the following setup (I am rewriting the actual values for
security purposes):
The mail server's IP is 111.111.111.111 which resolves to
mail.mysite.com
The webserver's IP is 222.222.222.222 which is www.mysite.com or
mysite.com

To prevent increasing SPAM attacks we modified the Mail MX records to
point to our ISP, which has the SPAM filter installed on their server
(121.121.121.121). All the SPAM filter does is - it strips sender
email's domain part and verifying it with sender's IP. If it is a
match, then ISP's server relying it to our mail server
(222.222.222.222)

Webserver's sendmail is working properly, but what happens is:
111.111.111.111 -121.121.121.121 X 222.222.222.222

When the email is originated at 111.111.111.111 - mail.mysite.com
(using PHP mail() function), the ISP's filter reads the sender email
address, compares it with IP, arrests the email, replying "You are not
222.222.222.222" and tries to bounce it back to 111.111.111.111.

We need to bypass that route for mail originated on the webserver,
hopefully by rewriting php.ini.

Apr 30 '07 #8

P: n/a
Max
I have tried rewriting php.ini, yet it did not produce desired
results.
Is there any other way, other than rewriting mail() function with our
own SMTP handler?

Apr 30 '07 #9

P: n/a
Max wrote:
I have read the php.net mail manual and am aware of the SMTP MTA
Windows redirect. The manual reads that php.ini SMTP string can be
configured for Windows servers only. I am aware of that. What I am
trying to accomplish is - to make it work in Linux setup.

Here is our scenario:

We have the following setup (I am rewriting the actual values for
security purposes):
The mail server's IP is 111.111.111.111 which resolves to
mail.mysite.com
The webserver's IP is 222.222.222.222 which is www.mysite.com or
mysite.com

To prevent increasing SPAM attacks we modified the Mail MX records to
point to our ISP, which has the SPAM filter installed on their server
(121.121.121.121). All the SPAM filter does is - it strips sender
email's domain part and verifying it with sender's IP. If it is a
match, then ISP's server relying it to our mail server
(222.222.222.222)

Webserver's sendmail is working properly, but what happens is:
111.111.111.111 -121.121.121.121 X 222.222.222.222

When the email is originated at 111.111.111.111 - mail.mysite.com
(using PHP mail() function), the ISP's filter reads the sender email
address, compares it with IP, arrests the email, replying "You are not
222.222.222.222" and tries to bounce it back to 111.111.111.111.

We need to bypass that route for mail originated on the webserver,
hopefully by rewriting php.ini.
Max,

Looks like you need to change the rules on your mail server to accept
(and relay) mail from 111.111.111.111.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 30 '07 #10

P: n/a
Max
Our mail server accepts emails from the webserver. Our emails are
going through default MX records, which point to our ISP server, which
does relay emails to our mail server. Simply put, I want to bypass the
MX record (which points to the ISP server's SPAM filter, which works
for us for all other mail, we have no control over)

Apr 30 '07 #11

P: n/a
Max
On Apr 27, 9:30 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Max wrote:
I have a question related to this post:
We are using 2 different Linux based servers: one for web (PHP, MySQL)
and another for the mail (Qmail, SquirrelMail e.t.c.). Our webserver
is co-located and mail server is installed here. For the PHP mail()
function to be able to use the mail server, I modified php.ini for
SMTP to pointi to the mail server' IP. Yet it still uses web server's
sendmail as SMTP MTA.
Please help

Did you define sendmail_path in your php.ini? Also, after changing your
php.ini, did you stop and restart your server?

What do you have for your sendmail parameters in your php.ini?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
The sendmail_path in php.ini was commented out. I have uncommened it
and set the value to nothing. I did restart Apache after that.

Apr 30 '07 #12

P: n/a
Max wrote:
Our mail server accepts emails from the webserver. Our emails are
going through default MX records, which point to our ISP server, which
does relay emails to our mail server. Simply put, I want to bypass the
MX record (which points to the ISP server's SPAM filter, which works
for us for all other mail, we have no control over)
In that case you'd have to look at your Unix/Linux configuration. PHP
knows nothing about MX records.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 1 '07 #13

P: n/a
Max wrote:
On Apr 27, 9:30 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Max wrote:
>>I have a question related to this post:
We are using 2 different Linux based servers: one for web (PHP, MySQL)
and another for the mail (Qmail, SquirrelMail e.t.c.). Our webserver
is co-located and mail server is installed here. For the PHP mail()
function to be able to use the mail server, I modified php.ini for
SMTP to pointi to the mail server' IP. Yet it still uses web server's
sendmail as SMTP MTA.
Please help
Did you define sendmail_path in your php.ini? Also, after changing your
php.ini, did you stop and restart your server?

What do you have for your sendmail parameters in your php.ini?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

The sendmail_path in php.ini was commented out. I have uncommened it
and set the value to nothing. I did restart Apache after that.
True, I forgot - that's a Windows only parameter. For Linux you need
sendmail or sendmail substitute on your system.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 1 '07 #14

P: n/a
Max wrote:
Our mail server accepts emails from the webserver. Our emails are
going through default MX records, which point to our ISP server, which
does relay emails to our mail server. Simply put, I want to bypass the
MX record (which points to the ISP server's SPAM filter, which works
for us for all other mail, we have no control over)
"Jerry Stuckle" <js*******@attglobal.netwrote:
: In that case you'd have to look at your Unix/Linux configuration. PHP
: knows nothing about MX records.

MX is pure DNS. It points to a mail server which usually opens port
25 up for SMTP and port 110 for POP3. PHP tends to run under an
Apache server which in turn opens port 80, unless one configures
weird/different things with port numbers.

Note, every IP address includes a port number, and a full connect
cannot be established without supplying the 5th element of the IP
address (the port number).

11.11.11.11:80 is a different IP address than 11.11.11.11:25.

When an SMTP server wants to relay mail to your mail server, it
issues an MX (DNS) query. PHP runs underneath Apache, but
I thought I read something somewhere that PHP can make and
accept connections on other ports. Perhaps, I'm getting it mixed
up with some Perl things I've read?

Anyways, that tends to be the way I think of it all. Please correct
me if anything I've stated is wrong.

http://us2.php.net/manual/en/ref.sockets.php
http://us2.php.net/manual/en/function.socket-bind.php
http://us2.php.net/manual/en/function.fsockopen.php

It almost appears that PHP can become a fully functional SMTP
server and/or POP3/IMAP server.

--
Jim Carlock
Post replies to the group.
May 1 '07 #15

P: n/a
Jim Carlock wrote:
Max wrote:
>Our mail server accepts emails from the webserver. Our emails are
going through default MX records, which point to our ISP server, which
does relay emails to our mail server. Simply put, I want to bypass the
MX record (which points to the ISP server's SPAM filter, which works
for us for all other mail, we have no control over)

"Jerry Stuckle" <js*******@attglobal.netwrote:
: In that case you'd have to look at your Unix/Linux configuration. PHP
: knows nothing about MX records.

MX is pure DNS. It points to a mail server which usually opens port
25 up for SMTP and port 110 for POP3. PHP tends to run under an
Apache server which in turn opens port 80, unless one configures
weird/different things with port numbers.

Note, every IP address includes a port number, and a full connect
cannot be established without supplying the 5th element of the IP
address (the port number).

11.11.11.11:80 is a different IP address than 11.11.11.11:25.

When an SMTP server wants to relay mail to your mail server, it
issues an MX (DNS) query. PHP runs underneath Apache, but
I thought I read something somewhere that PHP can make and
accept connections on other ports. Perhaps, I'm getting it mixed
up with some Perl things I've read?
Sure, PHP can make and accept connections on other ports. It has
nothing to do with running under Apache. But PHP knows nothing about MX
records.

In fact, it knows nothing about A records, either. All it knows it it
can connect to a server by name, TCP/IP performs the DNS lookup
transparently.
Anyways, that tends to be the way I think of it all. Please correct
me if anything I've stated is wrong.

http://us2.php.net/manual/en/ref.sockets.php
http://us2.php.net/manual/en/function.socket-bind.php
http://us2.php.net/manual/en/function.fsockopen.php

It almost appears that PHP can become a fully functional SMTP
server and/or POP3/IMAP server.
It could be. But there's no implementation - and I suspect there never
will be. A SMTP server is quite complex. A POP3/IMAP server is less
so, but still complicated. Both would be quite slow in any interpreted
language.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 1 '07 #16

P: n/a
Max
Thank you for your posts. I appreciate your feeback.

I agree that PHP can connect to any port and SMTP port 25 is not an
issue.
What I want to accomplish is - instead of sending emails using
standard route (MX pointer): 111.111.111.111 -121.121.121.121 ->
222.222.222.222

I want to bypass that so that mail sent by PHP mail() function will be
forwarded directly: 111.111.111.111 -222.222.222.222

I will allow relay on 222.222.222.222 for 111.111.111.111.

I think it is possible to do on Windows machine by adding a record in
lmhosts file.

Can I do it on Linux, by rewriting php.ini or is it Qmail config?

May 1 '07 #17

P: n/a
Max wrote:
Thank you for your posts. I appreciate your feeback.

I agree that PHP can connect to any port and SMTP port 25 is not an
issue.
What I want to accomplish is - instead of sending emails using
standard route (MX pointer): 111.111.111.111 -121.121.121.121 ->
222.222.222.222

I want to bypass that so that mail sent by PHP mail() function will be
forwarded directly: 111.111.111.111 -222.222.222.222

I will allow relay on 222.222.222.222 for 111.111.111.111.

I think it is possible to do on Windows machine by adding a record in
lmhosts file.

Can I do it on Linux, by rewriting php.ini or is it Qmail config?
No, you can't do it by changing the PHP.INI file. On Linux you have to
connect to a smtp server on that machine. And once PHP dumps the mail
off to the MTA, there is nothing more it can do with it.

You need to follow up in a newsgroup related to your MTA and/or Linux
configuration. There isn't anything you can do with it in MySQL.

But those would all be bypasses. You should get your ISP to modify it's
MTA configuration to allow mail to be sent from your webserver also.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 1 '07 #18

This discussion thread is closed

Replies have been disabled for this discussion.