Jump to content

Hunting for the most simple and straightforward way to send an email


DWilliams

Recommended Posts

I'm admittedly very ignorant about email in general. I want some way to send emails in a way that just works . The receiver doesn't need to be able to reply so I don't want to mess with SMTP logins or anything. I have a list of email addresses that I want my script to loop through and send an email to each.

 

I messed with the mail() function and passed my own email address to it with a subject and body and executed the script but I never got the email. I assume I have to configure some server or something in php.ini. Now, this script is going to be redistributed so I want to reduce the hassle required to install/configure it.

 

Knowing this, can somebody link me to an article explaining the simplest way to send a very basic email? No HTML, no attachments, no replying, just simple subject/body email.

Link to comment
Share on other sites

A) The php mail() function is the simplest method of sending a basic email.

B) Whatever method you do use in a script you must take into account the requirements that the host for the sending mail server has set up.

C) Where exactly did you try your test script at, what sending mail server did you use (a local mail server or a remote one), and did you meet any requirements that the sending mail server expects, such as using SMTP Authentication to satisfy relaying restrictions or setting the From: address to be a valid mail box at the sending mail server?

Link to comment
Share on other sites

A) The php mail() function is the simplest method of sending a basic email.

B) Whatever method you do use in a script you must take into account the requirements that the host for the sending mail server has set up.

C) Where exactly did you try your test script at, what sending mail server did you use (a local mail server or a remote one), and did you meet any requirements that the sending mail server expects, such as using SMTP Authentication to satisfy relaying restrictions or setting the From: address to be a valid mail box at the sending mail server?

 

I guess I'm just misunderstanding something about the mechanics of email or something. I don't see the need for a mail server just for sending email. Isn't it a fairly simple process? Isn't there some library out there or something that can just open a socket to the receiver's mail server and follow SMTP to deposit the message then shut down without a need for installing/configuring a mail server?

 

 

provide a sample of what you did to pass the email to yourself..

 

I just created and executed a script on my local machine with the following contents:

 

<?php
mail('myemail@gmail.com', 'Testing...', 'hello world from PHP mail()');
?>

 

Link to comment
Share on other sites

I guess I'm just misunderstanding something about the mechanics of email or something. I don't see the need for a mail server just for sending email. Isn't it a fairly simple process? Isn't there some library out there or something that can just open a socket to the receiver's mail server and follow SMTP to deposit the message then shut down without a need for installing/configuring a mail server?

You need access to a mail server to send email. It doesn't have to be on your machine.  If you're running on Windows, you can install xampp which comes with the mail server Mercury/32 Mail Transport System. This mail server can also be downloaded directly from http://www.pmail.com/

 

Ken

Link to comment
Share on other sites

I guess I'm just misunderstanding something about the mechanics of email or something. I don't see the need for a mail server just for sending email. Isn't it a fairly simple process? Isn't there some library out there or something that can just open a socket to the receiver's mail server and follow SMTP to deposit the message then shut down without a need for installing/configuring a mail server?

You need access to a mail server to send email. It doesn't have to be on your machine.  If you're running on Windows, you can install xampp which comes with the mail server Mercury/32 Mail Transport System. This mail server can also be downloaded directly from http://www.pmail.com/

 

Ken

 

Well I'm not on Windows so I'll have to investigate how to set up another mail server.

 

Now my next question is: what would a potential installer of my script expect to have to configure as far as email goes? Should my script just use mail() when it needs to send an email and expect the configuration to be already done in php.ini or wherever it's set, or should my script-specific config file store the login details for somebody's gmail or something and use a library like phpmailer to send through it?

Link to comment
Share on other sites

What platform are you running?

 

In the php.ini file, look for the section labeled "[mail function]". This section defines the information you need to set.

 

Ken

 

I'm running Linux. Apparently I just need to install/configure sendmail according to the comments in php.ini

 

Although if it's in php.ini I assume that I can just use mail() in my script and assume the person with my script running has either configured php.ini correctly themselves or (more likely) their web host has done it for them?

 

Should I bother using ini_get to make sure there's at least something set for either SMTP or sendmail?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.