473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

PHP Email


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
17 1928
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Chuck Anderson | last post by:
Can anyone point me in the right direction? I want to use Php to automate confirmation of someone joining an email list by them replying to an email (so they don't have to have a browser?). I...
4
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email...
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
2
by: BSG-SMTP-Gateway | last post by:
The following message sent by this account has violated system policy: Connection From: 64.253.55.90 From: python-list@python.org To: terriss@birdsall.com, q4dzsAEAAAAA@birdsall.com,...
26
by: libsfan01 | last post by:
Hi all! Can anyone show me how to check and email field on a form for the existence of these two characters. Kind regards Marc
3
by: g0c | last post by:
hi, how to hide or replace email addresses in php mail function with something like "group" so the email addresses to which email is sent are not visible ? i have : $subs = "email1@dot.com,...
3
by: Erik Johnson | last post by:
THE GOAL: I need to send an email with a simple ASCII text body and an attached HTML file. I have scripts that send basic emails via the smtplib module that don't have any attachements and that...
15
by: Craig Hurley | last post by:
Hello, user@x.com receives an email from user@a.com. I want to forward that email to user@y.com. I want the contents/header to remain intact, with the exception of adding "X-Forwarded-For". ...
3
by: IGD | last post by:
I don't know if this is the right place to post this or not. If not, could someone direct me elsewhere where I would find more information on how to solve my problem? Thanks! My problem is this:...
27
matheussousuke
by: matheussousuke | last post by:
I'm having trouble with e-mail sending, I mean, the website is suposed to send a confirmation email after sign up, but it gets like text plain instead of HTML May someone help me, please? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.