What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Trouble sending email from PHP

Pages: (2): « First [ 1 ] 2 » Last »
Trouble sending email from PHP
Author: Message:
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. Trouble sending email from PHP
Ok, a bit of background first.

My boss at work asked to make a system to put bookings onto for various things (meetings, car parking spaces, contractors, company vehicles etc). I made it using PHP and mySQL and hosted it on www.freehostia.com, which seems to be quite a fully featured web host considering it's free. Everything was all working fine and the system took off quite well.

I was later asked to add a maintenance request form and integrate it, which didn't take much work because of the already exisiting framework for it. Now, he's asked me if it's possible to send him an email when a job is requested. Sure enough, I set about it... now this is where things get complicated.

I can't use PHP's mail() as we don't have an SMTP server to use (They're pushing to make it all completley free btw) and the hosting doesn't provide one.

I can't seem to use an external site's SMTP (such as smtp.gmail.com) as I can't edit my php.ini file on the web host.

I can't use the college system to send it as we are using an exchange server and have quite a strict policy on what we can do (I can't even connect an FTP client to a server from inside the college as I don't have permission, even though I actually have)

I've tried using an example demonstrating fsockopen to send the email, but it fails everytime with error 13 (permission denied), despite php.info reporting allow_open_urls to be true.

I need an idea how to just send an email, for free, from PHP, where I can spoof the headers to appear to be sent from within our domain and to set the reply-to address.

Any ideas? :s
<Eljay> "Problems encountered: shit blew up" :zippy:
11-03-2009 02:33 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Trouble sending email from PHP
PHPMailer? http://sourceforge.net/projects/phpmailer/files/p...er%20for%20php5_6/

This post was edited on 11-03-2009 at 02:54 PM by matty.
11-03-2009 02:54 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: Trouble sending email from PHP
I did try it, but no luck. It always says the message sent though, which makes me think the SMTP servers I'm using are at fault.

I think that's going to be the biggest problem. I'm not going to be able to use one for free. If I didn't have to keep switching between windows and ubuntu, I'd have set it up on my own local machine
<Eljay> "Problems encountered: shit blew up" :zippy:
11-03-2009 03:02 PM
Profile PM Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
RE: Trouble sending email from PHP
Why are you using that free site instead of the webspace I gave you?
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
11-03-2009 04:06 PM
Profile PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: Trouble sending email from PHP
It's a work thing. spunkylovemuff.co.uk wouldn't have looked very good, and I didn't want to have a sub-domain. I settled for a custom sub-domain that I can use for all work stuff.
<Eljay> "Problems encountered: shit blew up" :zippy:
11-03-2009 08:14 PM
Profile PM Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
RE: Trouble sending email from PHP
It looks like they have python setup you might be able to knock something up in python to send the mail then have your php just call the python function

example
Python code:
#!/usr/bin/env python
import cgi
import smtplib
fields=cgi.FieldStorage()
 
print "Content-Type: text/html"#the mime header
print
 
 
print """
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sender</title>
</head><body><center>"""

 
 
 
if 'message' in fields:
    message=fields["message"].value
else:
    message=None
   
if 'to' in fields:
    to=fields["to"].value
else:
    to=None
 
 
if bool(to)==True and bool(message)==True:
    server = smtplib.SMTP('smtp.gmail.com')
    server.set_debuglevel(1)
    server.ehlo()
    server.starttls()
    server.ehlo()
    #fill in those 3 fields then you can call like email.cgi?to=address&message=test
    server.login("""~~~~~~~~gmailuser~~~~~~~""", "~~~~Gmail password~~~~~~~~~")
    server.sendmail("~~~~from address~~~~~~~~~~", to, message)
    try:
        server.quit()
    except:
        pass
 
 
print"""
</body>
</html>"""

 


This post was edited on 11-03-2009 at 09:19 PM by Jarrod.

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














11-03-2009 09:06 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: Trouble sending email from PHP
Lol. Tried your idea Jarrod:

Forbidden
You don't have permission to access /email.cgi on this server.


Changed CHMOD and it "sent"... Never received it though. I can only assume that Gmail stopped allowing external SMTP use at some time =/

<Eljay> "Problems encountered: shit blew up" :zippy:
11-04-2009 10:45 AM
Profile PM Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
RE: Trouble sending email from PHP
quote:
Originally posted by Spunky
Lol. Tried your idea Jarrod:

Forbidden
You don't have permission to access /email.cgi on this server.


Changed CHMOD and it "sent"... Never received it though. I can only assume that Gmail stopped allowing external SMTP use at some time =/
tested it it works check your spam folder

edit you don't have to use gmail, universities often have smtp servers which will act as relays

This post was edited on 11-04-2009 at 11:02 AM by Jarrod.

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














11-04-2009 11:01 AM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
O.P. RE: Trouble sending email from PHP
Where's your script located and I'll give it a try... Still not working here...
<Eljay> "Problems encountered: shit blew up" :zippy:
11-04-2009 11:40 AM
Profile PM Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
RE: Trouble sending email from PHP
I checked it again, it def works, i don't need ppl abusing my gmail account or my macbook so check your pm's

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














11-04-2009 11:46 AM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On