/    Sign up×
Community /Pin to ProfileBookmark

PHP SMTP Mail – Help!

I am having a really hard time trying to figure out how to mail a form via email. I have tried downloading class.phpmailer.php and make a phpmailer object as in previous posts, along with other variations of mail.php shown below.

<?php

require_once “/lib/phpmailer/class.phpmailer.php”;
$mail = new phpmailer();
$mail->IsSMTP();
$mail->Host = “mail.whatever.com”; // verify that this is correct host
$mail->Port = 25; // verify that this is correct port on mail host
$mail->Username = “username”; // your login name on the mail host
$mail->Password = “password”; // your password on the mail host
$mail->From = “[email protected]“;
$mail->FromName = “Administrator”;
$mail->AddAddress(“[email protected]“);
$mail->Subject = “Password Retrieval”;
$mail->Body = “Password is: aaaaaaaa”;
$result = $mail->Send();
if($result)
{
// it worked
}
else
{

// it didn’t work, $mail->ErrorInfo will have any error message from phpmailer
}

?>

AND I tried this

<?
include(“Mail.php”);
/* mail setup recipients, subject etc */
$recipients = “[email protected]”;
$headers[“From”] = “[email protected]”;
$headers[“To”] = “[email protected]”;
$headers[“Subject”] = “User feedback”;
$mailmsg = “Hello, This is a test.”;
/* SMTP server name, port, user/passwd */
$smtpinfo[“host”] = “mail.whatever.com”;
$smtpinfo[“port”] = “25&#8243;;
$smtpinfo[“auth”] = true;
$smtpinfo[“username”] = “username”;
$smtpinfo[“password”] = “password”;
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory(“smtp”, $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
?>

Please help! I greatly appreciate it!

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@cjc1055Feb 06.2007 — Depends on your PHP version and your settings.. but all you need as far as php to send a message is:

$msg .="Message here";
$to ="[email protected]";
$subject ="Subject Here";
$mailheaders ="From: Name <[email protected]>n";
$mailheaders .="Reply-To: Name <[email protected]> n";
mail($to,$subject,$msg,$mailheaders);


You will have to edit your PHP.ini with the correct settings...
Copy linkTweet thisAlerts:
@L3zL1EauthorFeb 06.2007 — I have php5 and use iis.

These are my setting in PHP.ini

[mail function]

;For Win32 only.

smtp = mail.localhost.com

smtp_port25

;For Win32 only.

;sendmail_from = [email][email protected][/email]

;
Copy linkTweet thisAlerts:
@cjc1055Feb 06.2007 — What are you using to send mail currently? Do you have an account that you use?

You will want to remove the ; from the sendmail_from line.
Copy linkTweet thisAlerts:
@L3zL1EauthorFeb 06.2007 — I entered my email where [email][email protected][/email] is located.

I removed the ; and its still not working. Isn't there somewhere I need to enter my username and password for authentication?


<?php

$msg ="Message here";

$to ="[email protected]";

$subject ="Subject Here";

$mailheaders ="From: Name <[email protected]>n";

$mailheaders ="Reply-To: Name <[email protected]> n";

mail($to,$subject,$msg,$mailheaders);

?>

[mail function]

;For Win32 only.

SMTP = mail.host.com

smtp_port = 25

;For Win32 only.

;sendmail_from = [email][email protected][/email]

For Unix only.

;etc etc

Should I have taken out the ;?
Copy linkTweet thisAlerts:
@cjc1055Feb 06.2007 — Well... hopefully there is someone else here that can clarify my thoughts and get this working for you.

Here is whave I have done. My domains do not require authentication for outgoing emails, so I do not need a username and password, yours may.

For example.. if my email address was [email][email protected][/email]... my domain was mail.cfl.rr.com .. but not all domains are the same.. however you have it set up in outlook is how you would want to put it in your php.ini.
Copy linkTweet thisAlerts:
@hastxFeb 06.2007 — what is your smtp server?

in one spot you have mail.host.com and in another mail.localhost.com,

where is smtp running?
×

Success!

Help @L3zL1E spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...