Use PHPMailer to send message to self

ellescuba27

Member
Messages
273
Reaction score
3
Points
18
Don't know if this can be done or not.

I am using PHPMailer to send emails (I am aware of the 100 email limit).
I want to be able to use smtp to send messages to myself using PHPMailer. Basically, I am making a newspaper that anyone at my school can edit and I want to have a flag button for inappropriate content. I want to get email updates when someone flags an article so I can review it. But I don't want to have to have people to email me from their own email to alert me. I want the email to be automatically sent without a login, and I prefer not to use mailto: . So I use PHPMailer and have it email myself messages so that no user login is required (the site does it for you). However, while it says there is no error, I am not receiving the messages in Roundcube.

Here is my code:
Here I have a function to send mail:
PHP:
<?php
require_once('phpmailer/class.phpmailer.php');
$error = null;
function smtpmailer($to, $subject, $message, $winerror, $failerror) {
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.(website blocked)";
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->Username = "(username blocked)";
$mail->Password = "(password blocked)";
$mail->SetFrom('(email blocked)', '(website blocked)');
$mail->AddReplyTo("(email blocked)","(website blocked)");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddAddress($to, "Our Friend");
if(!$mail->Send()) {
$error = true;
echo $failerror;
} else {
$error = false;
echo $winerror;
}
}
?>
For a fact, I know this function works. I have tested it with other people and they recieved it fine. But when sending to myself, it didn't work. Here is how I called the function:
PHP:
smtpmailer("(email blocked)", "FLAG", "Here is why the article was flagged", "A message has been sent to the admins telling them to check on this article. Well done!", "The article was flagged. It may take a while for the admins to find it, as there was an error when the email was sent.");

When I send the mail, I get $winerror as the error message, so no error happened. But I don't receive any emails! I checked my junk too. So what's wrong??
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
So you are using x10hosting's SMTP or a third party?

You are sending it FROM "george@igor.x10.bz" TO "george@igor.x10.bz" ?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Try setting $mail->SMTPDebug = 2; to get more information from PHPMailer. The higher the number, the more information will be shown (though 4 looks to be the largest debug level). You can also edit phpmailer::smtp_send to dump $smtp->error (if any) after each call to an SMTP method.
 

ellescuba27

Member
Messages
273
Reaction score
3
Points
18
@descalzo using x10hosting's SMTP (username)@(subdomain name). And yes, FROM and To is same address.
PHPMailer link: phpmailer.worxware.com
@misson will try.

---------- Post added at 04:29 PM ---------- Previous post was at 04:20 PM ----------

I set SMTP_Debug to 4. I'll just paste the FROM_SERVER parts, as I feel like anything else might be revealing dangerous information (I see some IP Addresses, and some codes which are usually meant to hide something):
SMTP -> FROM SERVER:220-boru.x10hosting.com ESMTP Exim 4.69 #1 Sun, 27 Nov 2011 11:22:36 -0500 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
SMTP -> FROM SERVER: 250-boru.x10hosting.com Hello boru.x10hosting.com [(blocked IP address)] 250-SIZE (blocked random code) 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP
SMTP -> FROM SERVER:250 OK
SMTP -> FROM SERVER:250 Accepted
SMTP -> FROM SERVER:354 Enter message, ending with "." on a line by itself
SMTP -> FROM SERVER:250 OK id=(blocked id)
Everything going fine?
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Can you receive mail on that account from outside?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Very little of the SMTP conversation contains sensitive information. IP addresses are generally the addresses of the servers, which are a matter of public record (DNS records, in particular). The number after SIZE is the size of the message. Mostly, we want to see whether there are any error response codes (4XX or 5XX), but there appear to be none, which means boru.x10hosting.com accepted the e-mail for delivery. What happens when you send an e-mail to the X10 account from an account on another host?
 

ellescuba27

Member
Messages
273
Reaction score
3
Points
18
Oops so apparently it's not a problem with PHPMailer, Roundcube isn't receiving any mail. I sent from my Gmail with no luck.

And it sends emails to other people just fine.
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
It might not so much be RoundCube as the mail account. Try setting up a POP3 or IMAP client (cPanel will give you the configuration). Alternatively, you can use Google Apps for mail hosting rather than X10.
 

ellescuba27

Member
Messages
273
Reaction score
3
Points
18
Hi,
the incoming mail server port is 110, right?

---------- Post added at 12:16 AM ---------- Previous post was at 12:06 AM ----------

Yes, it is 110. Thanks for your help misson, it works like a dream!
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
For the benefit of others experiencing the same issue, what was your solution?
 

ellescuba27

Member
Messages
273
Reaction score
3
Points
18
I set up an email client. BUT I think I found the problem with Roundcube!
Instead of clicking (in CPanel) Webmail, then clicking "Go to Secure Webmail Login", I clicked "Email Accounts" and chose the default email account from the top of the list. I clicked More, then "Access Webmail". Then I could see all the webmail I had gotten over the past few days.

Setting up a client also worked, but is much slower and unreliable. So I will use the above solution for now.
 

exploretheway.com22

New Member
Messages
6
Reaction score
0
Points
0
Assign values for function variables - Re: Use PHPMailer to send message to self

Looks like you need to assign values for function variables before function is referenced and then call the function.
 
Top